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

NSURL

Apple is moving toward using URLs to specify file resources as well as network resources. They are replacing methods that refer to a file by path with methods that refer to the file with a file:// URL. Instead of using an NSString to hold a URL, Foundation wraps the URL string in an NSURL object. NSURL is used for both file URLs and network URLs:

NSURL *someFile = [NSURL fileURLWithPath: @"/Users/rclair/notes.txt"];
NSURL *website =
    [NSURL URLWithString:  @"http://www.chromaticbytes.com"];
NSLog(@"Host: %@ URL: %@", [someFile host], [someFile absoluteString]);
NSLog(@"Host: %@ URL: %@", [website host], [website absoluteString]);


  

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