Skip to content

carlj/NSURL-Parameters

Repository files navigation

#NSURL+Parameters Category to access the URL Parameters within your NSURL

Build Status

##Installation Just drag & drop the NSURL+Parameters.h and NSURL+Parameters.m to your project.

##Usage First of all take a look at the Example Project

NSURL *url = [NSURL URLWithString: @"http://example.com/index.php?foo=bar&test=one"];

//Access a value for a given parameter key
NSLog(@"parameter for key 'foo' = %@", [url parameterForKey:@"foo"]);
NSLog(@"parameter for key 'test' = %@", [url parameterForKey:@"test"]);

//Access a value for a given parameter key, with the literal syntax
NSLog(@"parameter for key 'foo' with literal syntax = %@", url[@"foo"]);
NSLog(@"parameter for key 'test' with literal syntax = %@", url[@"test"]);

//Access a value for a given parameter key, with the parameters property
NSLog(@"parameter for key 'foo' with parameters property = %@", url.parameters[@"foo"]);
NSLog(@"parameter for key 'test' with parameters property = %@", url.parameters[@"test"]);


//Access a escaped value for a given parameter key
NSString *urlString = @"http://example.com/index.php?foo=bar&test=one two";
urlString = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];

url = [NSURL URLWithString: urlString];

NSLog(@"parameter for key 'test' (shouldnt be escaped) = %@", [url parameterForKey:@"test"]);

##LICENSE Released under the MIT LICENSE

About

Category to access the URL Parameters within your NSURL

Resources

License

Stars

Watchers

Forks

Packages

No packages published