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

Using NSError

From: nserror.m

 6 NSError *error = nil;
 7 NSStringEncoding enc;
 8 NSString *str = [NSString
 9   stringWithContentsOfFile: @"DoesNotExist"
10               usedEncoding: &enc
11                      error: &error];
12 if (nil != error)
13 {
14   NSLog(@"Error: %@",
15       [error localizedDescription]);
16 }

A few of the methods that Apple introduced with OS X 10.2 take an NSString** as an argument. This is used to return a second value reporting an error. If the variable that this points to is nil after the call, the operation succeeded. If not, it contains a string describing error.


  

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