Shortening URLs

Cited from: http://tinyurl.com/yklfftw

NSString *url    = @”http://brandontreb.com”;
NSString *apiEndpoint = [NSString stringWithFormat:@”http://api.tr.im/v1/trim_simple?url=%@”,url];
NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint]
         encoding:NSASCIIStringEncoding
         error:nil];
NSLog(@”Long: %@ – Short: %@”,url,shortURL);
 
// Outputs Long: http://brandontreb.com – Short: http://tr.im/MRDd

Blogged with the Flock Browser
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: