On Fri, Sep 5, 2008 at 12:40 PM, steph thirion <[EMAIL PROTECTED]> wrote: > > from the selector of a given getter function, I need to get the selector of > the equivalent setter function. For instance, from color I should get > setColor. >
I assume you want to do more with the selector than just invoke it---otherwise you can just use KVC and save yourself some grief. There are a few cases you may encounter here: 1. There is no setter. 2. There is a setter and the class is KVC compliant for the key. 3. There is a setter and the class isn't KVC compliant for the key, but there is a setter defined as part of a property definition. 4. (3) but without the property definition. > char* getterName = sel_getName(getterSelector); > Instead of using C strings, you can use NSStrings and NSSelectorFromString() and NSStringFromSelector()---making string manipulation much easier. However, for case (3), you'll need to do some parsing of the property attribute list from property_getAttributes(). > What would be the less costly way, performance wise, to convert the C string > "color" to "setColor"? > > I have no experience in working with strings in objc, and was hoping someone > would point me in the right direction before I start. If you're working in Cocoa (and I assume you are, since this is a cocoa-dev list), this is a good starting point: <http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/> Phil _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]