• 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
NSKeyValueChangeNewKey returning NSNull
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSKeyValueChangeNewKey returning NSNull


  • Subject: NSKeyValueChangeNewKey returning NSNull
  • From: Kai BrĂ¼ning <email@hidden>
  • Date: Fri, 21 Dec 2007 19:50:49 +0100

Hi,

I have a case in which a KVO change dictionary always contains NSNull under NSKeyValueChangeNewKey and no idea why.

Observation is established like this:

	[objectToObserve addObserver:self forKeyPath:@"visiblePage"
		options:NSKeyValueObservingOptionNew
		context:whatever];

objectToObserve has this pair of accessors:

- (NSNumber*) visiblePage {
   return [NSNumber numberWithInt:_visiblePage];
}

- (void) setVisiblePage:(NSNumber*)value {
   _visiblePage = [value intValue];
}

which are declared in the interface, too:

- (NSNumber*) visiblePage;
- (void) setVisiblePage:(NSNumber*)value;

_visiblePage is an iVar of type int.

Any idea why the change dictionary would contain NSNull for NSKeyValueChangeNewKey in this case?
Note: - (NSNumber*) visiblePage is not called during the whole change process, but observeValueForKeyPath:ofObject:change:context: is called on the observing object, just with the defective change dictionary.


In a very similar case (identical observed class, slightly different observer) everything works well.

The workaround is obvious (using valueForKey: instead of depending on the change dictionary) and works, but I'd would prefer to understand this issue.

This is all with Xcode 3 under 10.5.1 with GC off.

Best,
Kai
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSKeyValueChangeNewKey returning NSNull
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: Nested NSViews and keyboard focus
  • Next by Date: Core Data load document store without document for QuickLook plugin
  • Previous by thread: RE: Using Interface Categories vs Interface Builder
  • Next by thread: Re: NSKeyValueChangeNewKey returning NSNull
  • Index(es):
    • Date
    • Thread