On Feb 28, 2010, at 23:12, Eagle Offshore wrote:

> Documentation?  "NSNull" does not appear in the documentation.
> http://developer.apple.com/mac/library/documentation/cocoa/reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html
> 
> NSNull is conceptually the wrapper for nil,

No, this is a false statement. See:

        
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNull_Class/Reference/Reference.html

"The NSNull class defines a singleton object used to represent null values in 
collection objects (which don’t allow nil values)."

Getting "the wrapper for nil" out of this is going a bit too far.

> like NSNumber is the wrapper for a number.

And this is a false statement (because of the word "like"). KVC has the 
built-in ability to transform numeric property values to and from NSNumber 
objects. There is no such behavior involving NSNull.

> It is conceptually inconsistent to treat them differently.

Therefore this is also a false statement. There is a certain superficial 
similarity between nil/NSNull and number/NSNumber, perhaps, but that's about 
all.

> NSMutableDictionary* dict = [NSMutableDictionary dictionary];
> 
> [dict setObject: 5 forKey: @"foo"]  // fails - must have object
> [dict setObject [NSNumber numberWithInt: 5] forKey: @"foo"]; // OK
> 
> [dict setObject: nil forKey: @"bar"] // fails - must have object
> [dict setObject: [NSNull null] forKey: @"bar"]; // OK
> 
> NSManagedObject* obj; // gets created somehow
> 
> [obj setValue: nil forKey: @"bar"]; // succeeds where NSDictionary fails
> [obj setValue: [NSNull null] forKey: @"bar"]; // fails where NSDictionary 
> succeeds

Of course it fails. '[dict setObject: ... forKey: @"bar"];' sets the object for 
a key in a dictionary. '[obj setValue: ... forKey: @"bar"];' sets the value of 
an object property. The two mechanisms are unrelated.

> so - this is conceptually buggy thinking and the thoughtful developer could 
> be forgiven for being VERY SURPRISED by this behavior that is NOT DOCUMENTED.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to