Mailing Lists: Apple Mailing Lists

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

Key-Observing, change, and NSNull



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



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.