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

NSAttributedString

Sometimes, you want to display a string that has certain attributes for a range of characters. For example, suppose that you want to display the string “Big Nerd Ranch” and want the letters 0 through 2 to be underlined, the letters 0 through 7 to be green, and the letters 9 through 13 to be subscripts.

When dealing with a range of numbers, Cocoa uses the struct NSRange, which has two members—location and length—both of which are integers. The location is the index of the first item, and the length is the number of items in the range. You can use the function NSMakeRange() to create an NSRange.


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint