-
-
Save kkdai/f6ee743172f6c2ca67e4 to your computer and use it in GitHub Desktop.
taipei opendata test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *url = [NSURL URLWithString:@"http://opendata.dot.taipei.gov.tw/opendata/alldescriptions.json"]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:url]; | |
[NSURLConnection sendAsynchronousRequest:request | |
queue:[NSOperationQueue mainQueue] | |
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { | |
unsigned long big5 = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingBig5_HKSCS_1999); | |
NSString *json = [[NSString alloc] initWithData:data encoding:big5]; | |
NSError *error; | |
NSDictionary *dictionary = | |
[NSJSONSerialization JSONObjectWithData:[json dataUsingEncoding:NSUTF8StringEncoding] | |
options:kNilOptions | |
error:&error]; | |
NSLog(@"dict %@", dictionary); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
可以解決iOS 連接JSON的編碼問題..