Skip to content

Instantly share code, notes, and snippets.

@minsOne
Created June 30, 2014 07:02
Show Gist options
  • Select an option

  • Save minsOne/4c170095a5c3b2ef7c7a to your computer and use it in GitHub Desktop.

Select an option

Save minsOne/4c170095a5c3b2ef7c7a to your computer and use it in GitHub Desktop.
- (NSString *)encodeURL:(NSString *)url {
NSString * encoded = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef)url,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
return encoded;
}
// _data = [[NSMutableData alloc] init];
// NSMutableURLRequest *request;
// NSString *longUrl = @"http://www.google.com/";
//
// request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.googleapis.com/urlshortener/v1/url"]
// cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
// timeoutInterval:60.0];
//
// [request setHTTPMethod:@"POST"];
// [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
// [request setHTTPBody:[[NSString stringWithFormat:@"{\"longUrl\": \"%@\"}", longUrl] dataUsingEncoding:NSUTF8StringEncoding]];
//
// [NSURLConnection connectionWithRequest:request delegate:self];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment