URLByAppendingPathExtension:
Returns a new URL made by appending a path extension to the original URL.
- (NSURL *)URLByAppendingPathExtension:(NSString *)pathExtension
Parameters of [NSURL URLByAppendingPathExtension]
- pathExtension
- 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:@"http://foo.com/bar/baz"];
NSURL *appendExtension = [baseURL URLByAppendingPathExtension:@"qux"];
NSURL *appendComponent = [baseURL URLByAppendingPathComponent:@"qux"];
STAssertEqualObjects([appendExtension absoluteString], @"http://foo.com/bar/baz.qux", nil);
STAssertEqualObjects([appendComponent absoluteString], @"http://foo.com/bar/baz/qux", nil);
Example of [NSURL URLByAppendingPathExtension]
NSURL *originalURL = [NSURL URLWithString:@"http://hello.com/news"];
NSLog(@"%@", [originalURL URLByAppendingPathComponent:@"local"]);
NSLog(@"%@", [originalURL URLByAppendingPathExtension:@"local"]);