Re: string convertion: converting getter name to setter
Re: string convertion: converting getter name to setter
- Subject: Re: string convertion: converting getter name to setter
- From: Phil <email@hidden>
- Date: Fri, 5 Sep 2008 14:17:01 +1200
On Fri, Sep 5, 2008 at 1:53 PM, Steve Weller <email@hidden> wrote:
>
> From memory I think that does not work: capitalizedString also decapitalizes
> all but the first character, so capitalizedString will become
> setCapitalizedstring instead of setCapitalizedString.
>
Gah, you're right! I guess the only way to do it then is with an
NSMutableString:
NSMutableString *getterName = [NSStringFromSelector(...) mutableCopy]
[getterName replaceCharactersInRange:NSMakeRange(0, 1)
withString:[[getterName substringToIndex:1] uppercaseString]];
Maybe it is easier with C strings:
const char *getterName = sel_getName(...)
char *getterName_m = strdup(getterName);
getterName_m[0] = toupper(getterName_m[0]);
// and clean up...
Phil
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden