次の方法でサーバーにリクエストを送信しています。
- (void) getData
{
NSString *url= @"http://example.com";
NSMutableURLRequest *theRequest= [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
exampleConnection =[[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];
}
そして、このための応答はJSONファイルであり、次のように解析しています。
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"Connection did finish loading %@",[connection currentRequest]);
NSDictionary *exampleDictionary = [NSJSONSerialization JSONObjectWithData:receivedData options: NSJSONReadingAllowFragments error:nil];
NSLog(@"%@", exampleDictionary); // which gives me null
}
応答は以前は正常に機能しました。しかし、今ではnullが返されます。これは、JSONからNSDictionaryへの変換を何かが妨げているためです。調査したところ、問題は、解析プロセスがうまくいかなかった外国人のキャラクター(中国語など)が2人いたことが原因であることがわかりました。
この問題を解決する方法がわかりません。誰かアイデアはありますか?