On Jul 18, 2012, at 20:31 , Graham Cox wrote:

> However, I'm not sure whether, if you pass a string to -setValue:forKey: and 
> the property is numeric, whether a conversion to an NSNumber is done there, 
> or whether the object would just store the string. That might cause problems.

If the property is a scalar numeric, KVC examines the property type and boxes 
or unboxes the scalar value to NSNumber or from the object it's given. Passing 
a string can indeed cause problems, though. The following code, for example, 
will throw an exception:

        @property unsigned int myValue;
        …
        [someObject setValue: @"1" forKey: @"myValue"];

(Hint: look up the documentation for -[NSString unsignedIntValue].)
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com

Reply via email to