Video Tutorial: NSString

Ray Wenderlich

Challenge

Your challenge is to write some code that generates Elmo’s song [video] [lyrics], given an arbitrary list of pipe-separated names, like this:

NSString *namesList = @"Elmo|Big Bird|Snuffy";
NSMutableString *finalSong = [NSMutableString string];
// Your code here!
NSLog(@"%@", finalSong);

Hints:

  • You will probably need to use appendString:, appendFormat:, and componentsSeparatedByString: to accomplish this.
  • Notice there are is a slight variance between verses – the first time it’s “He loves to sing”, the rest is “I love to sing.”
  • Notice the ending also varies depending on whether it’s the first, middle, or final person.

Download demo code

Download challenge solution

Helpful links

Ray Wenderlich

Ray is part of a great team - the raywenderlich.com team, a group of over 100 developers and editors from across the world. He and the rest of the team are passionate both about making apps and teaching others the techniques to make them.

When Ray’s not programming, he’s probably playing video games, role playing games, or board games.

Other Items of Interest

Save time.
Learn more with our video courses.

raywenderlich.com Weekly

Sign up to receive the latest tutorials from raywenderlich.com each week, and receive a free epic-length tutorial as a bonus!

Advertise with Us!

PragmaConf 2016 Come check out Alt U

Our Books

Our Team

Video Team

... 20 total!

Swift Team

... 15 total!

iOS Team

... 43 total!

Android Team

... 14 total!

macOS Team

... 11 total!

Unity Team

... 11 total!

Articles Team

... 12 total!

Resident Authors Team

... 15 total!