Re: KVC not allowing setValue:forKey: on ints [Solved]
Re: KVC not allowing setValue:forKey: on ints [Solved]
- Subject: Re: KVC not allowing setValue:forKey: on ints [Solved]
- From: Guy English <email@hidden>
- Date: Mon, 2 Apr 2007 01:56:48 -0400
- (void) setValue: (id) value forKey: (NSString*) key; takes an
object for it's first param. The documentation is referring to the
fact that you can *bind* that key to the intValue of some other
object. But the automatic wrapping won't take place when you're
calling it directly as you are in this code.
Thanks Guy, Hal and Chris.
Ken
Hope that helps,
Guu
Pleasure. But for the archives 'Guu' isn't my real name. :)
The 'magic' that's happening is that when you bind what's basically
happening is that one object asks the other for it's valueForKey:.
The signature for valueForKey is: - (id) valueForKey: (NSString*)
key. So:
[self setValue: [otherObject valueForKey: "bobo"] forKey: @"bobo"];
works because the valueForKey call has wrapped the value for it. Now
I say "basically" because that's what's happening *conceptually* in
reality the value is given to the observe key path method. But the
params to that are passed in a dictionary and as such are also pre-
wrapped for you.
Later,
Guy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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