/CSURITemplate

Objective-C implementation of the URI Template spec.

Primary LanguageObjective-CMIT LicenseMIT

CSURITemplate

Build Status

CSURITemplate is an Objective-C implementation of RFC6570: URI Template up to Level 4 of the spec.

Example usage:

NSError *error = nil;
CSURITemplate *template = [CSURITemplate URITemplateWithString:@"{?list*}"
                                                         error:&error];
NSDictionary *variables = @{@"list": @[@"red", @"green", @"blue"]};
NSString *uri = [template relativeStringWithVariables:variables error:&error];
assert([uri isEqualToString:@"?list=red&list=green&list=blue"]);

NSURL *baseURL = [NSURL URLWithString:@"http://www.example.com"];
NSURL *URL = [template URLWithVariables:variables relativeToURL:baseURL error:&error];
assert([uri isEqualToString:@"http://www.example.com?list=red&list=green&list=blue"]);

Installation

CocoaPods is the easiest way to use CSURITemplate.

platform :ios, '6.0'
pod 'CSURITemplate'