Re: KVC setter selector from property name
Re: KVC setter selector from property name
- Subject: Re: KVC setter selector from property name
- From: Andrei Tchijov <email@hidden>
- Date: Thu, 8 Dec 2005 17:58:46 -0500
It can be achieved (and it is) with "setValue:forKey:", but my
problem is that an Object which I need to apply KVC is subclass of
NSMutableDictionary, so instead of going "standard way" :
- setter,
- _... member,
- unknownKey,
it jumps straight to -[ NSMutableDictionary setValue:forKey: ]. So I
end-up checking if object respond to setter and then invoking setter
directly. I was just too lazy to write this:
- (SEL) setterForProperty: (NSString*) name {
NSString* firstChar = [[ name substringToIndex: 1 ] uppercaseString ];
NSString* restOfIt = [ name substringFromIndex: 1 ];
NSString* setterString = [ NSString stringWithFormat: @"set%@%@:",
firstChar, restOfIt ];
return NSSelectorFromString( setterString );
}
and could believe that Apple does not have this kind of function
available.
On Dec 8, 2005, at 5:51 PM, mmalcolm crawford wrote:
On Dec 8, 2005, at 12:10 PM, Andrei Tchijov wrote:
I can not believe that there is no some sort of helper function to
convert @"foo" into @selector( setFoo: ) (or at least to
@"setFoo:" ). But I can not find it.
What are you trying to achieve (that cannot be achieved using
setValue:forKey:...)?
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden