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: Ken Tozier <email@hidden>
- Date: Mon, 2 Apr 2007 01:36:18 -0400
On Apr 2, 2007, at 1:39 AM, Guy English wrote:
Hi,
- (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.
Ah. OK.
Thanks Guy, Hal and Chris.
Ken
Hope that helps,
Guu
On 2-Apr-07, at 1:03 AM, Ken Tozier wrote:
Hi
I read the key-value coding documentation and it specifically
states that you should be able to set values without having to
first pack them into an object
"Key-value coding supports properties that are objects, as well as
the scalar data types and structures that are supported by
NSNumber and NSValue. Non-object parameters and return types are
detected and automatically wrapped, and unwrapped, as required."
So how come when I go to compile my project with setValue:forKey:
I get " error: invalid conversion from 'int16' to 'objc_object*'"
For example:
@interface Foo : NSObject
{
int bobo;
}
@end
@implementation Foo
- (id) initFoo
{
self = [super init];
if (self)
{
[self setValue: 10
forKey: @"bobo"];
}
return self;
}
@end
What am I messing up here?
Thanks for any help
Ken
_______________________________________________
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:
40gmail.com
This email sent to email@hidden
_______________________________________________
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