Wednesday, May 1, 2013

NSURL URLByAppendingPathExtension example ios


Returns a new URL made by appending a path extension to the original URL.
- (NSURL *)URLByAppendingPathExtension:(NSString *)pathExtension
Parameters of [NSURL URLByAppendingPathExtension]
The path extension to add to the URL.
Return Value
A new URL with pathExtension appended.
Discussion of [NSURL URLByAppendingPathExtension]
If the original URL ends with one or more forward slashes, these are removed from the returned URL. A period is inserted between the two parts of the new URL.
Example of [NSURL URLByAppendingPathExtension]
NSURL *baseURL = [NSURL URLWithString:@""];
NSURL *appendExtension = [baseURL URLByAppendingPathExtension:@"qux"];
NSURL *appendComponent = [baseURL URLByAppendingPathComponent:@"qux"];

STAssertEqualObjects([appendExtension absoluteString], @"", nil);
STAssertEqualObjects([appendComponent absoluteString], @"", nil);
Example of [NSURL URLByAppendingPathExtension]
NSURL *originalURL = [NSURL URLWithString:@""];
NSLog(@"%@", [originalURL URLByAppendingPathComponent:@"local"]);
NSLog(@"%@", [originalURL URLByAppendingPathExtension:@"local"]);