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
  • PrintPrint

Strings Files

What do you do about string literals and string constants in your source code? Consider this source code from the previous chapter:

   UIAlertView *alert = [[UIAlertView alloc]
       initWithTitle:@"Error accessing photo library"
             message:@"Device does not support a photo library"
            delegate:nil
   cancelButtonTitle:@"Drat!"
   otherButtonTitles:nil];
   [alert show];

If you’ve gone through the effort of localizing your application for a particular audience, you certainly don’t want to be presenting alerts written in the development base language. The answer is to store these strings in special text files called strings files.

What’s in a Strings File?

Strings files are nothing more than Unicode (UTF-16) text files that contain a list of string pairs, each identified by a comment. Here is an example of what a strings file might look like in your application:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

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

  

Start a Free 10-Day Trial


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