• 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: KVG generic enough?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: KVG generic enough?
      • From: Graham Cox <email@hidden>
References: 
 >KVG generic enough? (From: William Squires <email@hidden>)
 >Re: KVG generic enough? (From: Marco Tabini <email@hidden>)
 >Re: KVG generic enough? (From: William Squires <email@hidden>)
 >Re: KVG generic enough? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: KVG generic enough?
  • Next by Date: Re: KVG generic enough?
  • Previous by thread: Re: KVG generic enough?
  • Next by thread: Re: KVG generic enough?
  • Index(es):
    • Date
    • Thread