• 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: KVC, binding multiple properties, top level object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC, binding multiple properties, top level object


  • Subject: Re: KVC, binding multiple properties, top level object
  • From: Trygve Inda <email@hidden>
  • Date: Sun, 13 Jul 2014 10:18:53 -0700
  • Thread-topic: KVC, binding multiple properties, top level object

>
> On 12 Jul 2014, at 10:05 pm, Trygve Inda <email@hidden> wrote:
>
>> ---someProperty (Custom NSObject)
>> ------propertyA (NSNumber)
>> ------propertyB (NSNumber)
>> ------propertyC (NSNumber)
>>
>> Properties A, B and C use a binding to connect them to a user interface item
>> with something like:
>>
>> Bind to MyObject with key path someProperty.propertyA
>
>
> Just as a matter of interest, why do you decalre these subproperties as
> NSNumber types? Is there a reason you can't just make them the native scalar
> types they wrap (e.g. integer, float)? KVC/KVO automatically wraps scalar
> values with NSNumber or NSValue to pass them around through bindings, so you
> don't have to concern yourself with it. Usually, code is clearer if properties
> are declared as the native types. If you make them NSNumbers, how will you
> detect or prevent a value of the wrong type being passed?
>
> --Graham
>
>
>

Would using NSInteger (instead of NSNumber) still work right when doing KVC
in something like:


-(void)encodeWithCoder:(NSCoder *)coder;
{
    for (NSString* key in [self propertyKeys])
        [coder encodeObject:[self valueForKey:key] forKey:key];
}


What gets returned from [self valueForKey:key]? I guess the system wrapes
the NSInteger in an NSNumber?




_______________________________________________

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


References: 
 >Re: KVC, binding multiple properties, top level object (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Issue with -[NSOutlineView autosaveExpandedItems] - SOLVED
  • Next by Date: -[NSOutlineView autosaveExpandedItems] bug?
  • Previous by thread: Re: KVC, binding multiple properties, top level object
  • Next by thread: Re: KVC, binding multiple properties, top level object
  • Index(es):
    • Date
    • Thread