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