Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The NSString class provides a nice object-oriented interface to represent, interact with, and modify a string of characters. Unlike in a C-style char * null-terminated string or char[] array, all aspects of memory allocation, text encoding, and string manipulation are hidden from the application developer as internal implementation details of the NSString class. This allows you to worry about the more important and unique aspects of your application logic rather than the nitty-gritty details of how strings are stored in a computer or how operations such as string concatenation operate.
This abstraction also means that common sources of error, such as attempting to store a 250-character string in a variable that has allocated space for only 200 characters, are easily avoided in Objective-C. Let’s start our discussion of strings by learning how to create new strings in your source code.