Re: KVG generic enough?
Re: KVG generic enough?
- Subject: Re: KVG generic enough?
- From: Quincey Morris <email@hidden>
- Date: Wed, 18 Jul 2012 20:53:24 -0700
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 (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