DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

StringWithFormat In ObjectiveC/Cocoa

08.12.2011
| 3913 views |
  • submit to reddit
        Objective C 's NSString has a method <a href="http://programmingbulls.com/stringwithformat">Stringwithformat</a> to translate strings and store in NSString. This works similar to printf in C. The example work as below:

NSString *firstName;
NSString *secondName;
 
firstName = @"David ";
secondName = @"Miller ";
 
NSString *fullName = [NSString stringWithFormat:@"%@ %@", firstName,secondName];