Video Tutorial: NSString

The first video in our Foundation series. Learn how to work with NSString, including a discussion of Unicode and character encodings.

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

Add a rating for this content

Contributors

Comments