• 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 setter selector from property name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >KVC setter selector from property name (From: Andrei Tchijov <email@hidden>)
 >Re: KVC setter selector from property name (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Odd behaviour in setContentView:
  • Next by Date: RE: Odd behaviour in setContentView:
  • Previous by thread: Re: KVC setter selector from property name
  • Next by thread: menu-free app (problem solved)
  • Index(es):
    • Date
    • Thread