In Apple's iOS 7 Tech Talks, the class NSURLComponents
was mentioned. It's a very useful utility for manipulating URLs (examples taken and modified from Apple):
NSURLComponents* components = [[NSURLComponents alloc] init];
components.scheme = @"https";
components.user = @"pmarcos";
components.password = @"seecret";
components.host = @"example.com";
components.path = @"/site/doc.html";
components.fragment = @"section3";
NSURL* url = components.url;
and:
NSURLComponents* components = [NSURLComponents componentsWithString:@"https://pmarcos:seecret@example.com/site/doc.html#section3"];
components.password = @"changed";
NSURL* secretPigFaceURL = components.URL;
//https://pmarcos:changed@example.com/site/doc.html#section3
At the time of writing, there are no docs for NSURLComponents,
so you'll have to refer to the NSURL.h
header file.
Download the iOS 7 Tech Talks videos and slides.
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.