Top > NSString

NSObject

  • Objective-c iPhone percent encode a string?
    • http://stackoverflow.com/questions/3423545/objective-c-iphone-percent-encode-a-string The iOS 7 SDK now has a better alternative tostringByAddingPercentEscapesUsingEncoding that does let you specify that you want all characters escaped except certain allowed ones. It works well if you are building up the URL in parts:
      NSString * unescapedQuery = [[NSString alloc] initWithFormat:@"?myparam=%d", numericParamValue];
      NSString * escapedQuery = [unescapedQuery stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
      NSString * urlString = [[NSString alloc] initWithFormat:@"http://ExampleOnly.com/path.ext%@", escapedQuery];
char str_c[100];
strcpy(str_c,"abc");
NSString *str = [ [ NSString alloc ] initWithUTF8String:str ];

Reload   Diff   Front page List of pages Search Recent changes Backup Referer   Help   RSS of recent changes
Last-modified: Tue, 14 Oct 2014 01:39:35 JST (3474d)