JSONTouch で JSON デシリアライゼーションを実行していますが、時間がかかりすぎて UI をブロックしているため、シリアライゼーションをバックグラウンド スレッドに入れるために GCD バックグラウンド キューを作成しようとしました。正常に動作する場合もありますが、場合によっては EXC_BAD_ACCESS が発生しdeserializeAsDictionary:weakSelf.mutableData error:&theError];
ます。
なぜだか途方に暮れています。mutableData をアトミック プロパティにしました。一度に 3 つのリクエストを作成しているので、mutableData にアクセスしようとしているスレッドと関係があると思いますか? または、ブロックの実行時に mutableData が適切な状態にない可能性がありますか?
どうもありがとう!
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
__weak myViewController *weakSelf = self;
dispatch_queue_t updateQueue = dispatch_queue_create("parse json", NULL);
dispatch_async(updateQueue, ^{
NSError *theError = nil;
// This is the call that gives me EXC_BAD_ACCESS
NSDictionary *dict = [[CJSONDeserializer deserializer]
deserializeAsDictionary:weakSelf.mutableData error:&theError];
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf setMutableData: nil];
});
});
dispatch_release(updateQueue);
}