• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Key-Observing, change, and NSNull
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Key-Observing, change, and NSNull


  • Subject: Key-Observing, change, and NSNull
  • From: Edwin Vane <email@hidden>
  • Date: Thu, 11 Aug 2005 09:31:55 -0400
  • Mail-followup-to: Cocoa-Dev <email@hidden>

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Key-Observing, change, and NSNull
      • From: Edwin Vane <email@hidden>
  • Prev by Date: Re: NSImageView doesn't change with setImage
  • Next by Date: Set path for col 0 in NSBrowser
  • Previous by thread: Re: Mouse over icon?
  • Next by thread: Re: Key-Observing, change, and NSNull
  • Index(es):
    • Date
    • Thread