Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key-Observing, change, and NSNull



For anybody following along, I removed the controller and bound the view
directly to the model. Now the change dictionary is correct.

Before this, I tried subclassing NSObjectController and overriding the
observed... method to see what value the controller was getting. It too
was NSNull. I can't imagine there being a problem with the object
controller but seeing as though the change directory is correct
without the controller it it sure seems that
way. Perhaps there is a setting I should have changed (The
NSObjectController's object class can remain the default of
NSMutableDictionary right? Or should I change this to the class type of
the object it's managing?

Another theory: perhaps non-object values don't pass
correctly through the controller via the change dictionary. An
experiment for later...

Edwin V

On Thu, Aug 11, 2005 at 09:31:55AM -0400, Edwin Vane wrote:
> Hi,
> 
> Doing some google and apple lists searching I've found a few people with
> this problem but no real resolution. Perhaps somebody will know the
> answer now.
> 
> I have a custom view in which I've overridden the bind method to set up
> observers for things in an NSObjectController instance. After the nib
> containing my views and the NSObjectController is loaded, I call bind
> the following way:
> 
> 	[tempoView bind: @"viewLoc" toObject: tempoTimeController
>        withKeyPath:@"selection.viewLoc" options:nil];
>       
>    [tempoView bind: @"unitsPerPixel" toObject: tempoTimeController
>        withKeyPath: @"selection.unitsPerPixel" options:nil];
> 
> The content outlet of the object controller has been set properly in IB.
> 
> I add observers in the overridden bind method as follows:
> 
> 		[_observedObjectForViewLoc addObserver:self
>                                   forKeyPath:_observedKeyPathForViewLoc
>                                      options:NSKeyValueObservingOptionNew
>                                      context:ViewLocContext];
> 
> Please note that viewLoc is an NSPoint and the unitsPerPixel is a simple
> float.
> 
> Now, observeValueForKeyPath is being triggered when a change happens
> except the value of the NSKeyValueChangeNewKey key in the change
> dictionary is always NSNull. I access the dictionary this way:
> 
> [change objectForKey:NSKeyValueChangeNewKey]
> 
> What I don't understand is this whole process is very similar to the
> GraphicsBinding example at:
> http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
> 
> and yet they are able to get correct NSRect change values. Any ideas why
> my change values aren't appearing correctly?
> 
> -- 
> 
> Edwin Vane
>    MMath Candidate
>    Computer Graphics Lab
>    School of Computer Science
>    University of Waterloo
> 
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
> 
> This email sent to email@hidden
> 

-- 

Edwin Vane
   MMath Candidate
   Computer Graphics Lab
   School of Computer Science
   University of Waterloo

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Key-Observing, change, and NSNull (From: Edwin Vane <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.