Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

1. The Basics > 1.8. Allocating and Making Use of Strings

1.8. Allocating and Making Use of Strings

Problem

You want work with strings in Objective-C

Solution

Use NSString and NSMutableString classes.

Discussion

The NSString and NSMutableString classes allow you to store a string of characters in memory. The NSString class is immutable, meaning that once it is created, its contents cannot be modified. Mutable strings represented with the NSMutableString can be modified once they are created. We will see an example of both of these classes very soon.

Objective-C strings should be placed inside double quotes. The starting double-quote should be prefixed with an at sign (@). For instance, the sentence Hello, World, represented as a string in Objective-C, is written like so:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial