• 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: NSString camel case
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString camel case


  • Subject: Re: NSString camel case
  • From: Dave Keck <email@hidden>
  • Date: Sat, 11 Apr 2009 20:46:38 -1000

Cocoa has always been lacking in the RegEx department (at least the
'built-in' Cocoa classes, there's a bunch of third-party regex
frameworks), especially when compared to languages like Python. Since
your situation isn't very complex, I would just use the bread-n-butter
string APIs:

NSString *originalString = @"everything_else_is_my_name";
    NSArray *originalStringComponents,
            *resultingComponents;
    NSMutableString *result = [NSMutableString string];

    originalStringComponents = [originalString
componentsSeparatedByString: @"_"];

    for (NSString *currentStringComponent in originalStringComponents)
        [result appendString: [NSString stringWithFormat: @"%@%@",
[currentStringComponent capitalizedString],

(currentStringComponent != [originalStringComponents lastObject] ? @"
" : @"")]];

    NSLog(@"%@", result);

(Better-formatted version here: http://pastie.org/444173).

Note that this snippet isn't incredibly efficient, but should get the
point across...

David
_______________________________________________

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

  • Follow-Ups:
    • Re: NSString camel case
      • From: "email@hidden" <email@hidden>
References: 
 >NSString camel case (From: Devraj Mukherjee <email@hidden>)

  • Prev by Date: Re: NSString camel case
  • Next by Date: Re: [SOLVED] Rendering OpenGL in timed loop (CoreVideo).
  • Previous by thread: Re: NSString camel case
  • Next by thread: Re: NSString camel case
  • Index(es):
    • Date
    • Thread