• 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
Re: Key-Observing, change, and NSNull
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key-Observing, change, and NSNull


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

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:
>
> 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:

This email sent to email@hidden

  • Follow-Ups:
    • Trivial Bindings question
      • From: John Stiles <email@hidden>
References: 
 >Key-Observing, change, and NSNull (From: Edwin Vane <email@hidden>)

  • Prev by Date: Re: Distributed Objects between cats
  • Next by Date: [Moderator] Re: Option-click on my app hides the other app
  • Previous by thread: Key-Observing, change, and NSNull
  • Next by thread: Trivial Bindings question
  • Index(es):
    • Date
    • Thread