OK私はこれのために多くの異なる方法を試しました。JSON API を呼び出し、その応答を取得し、キー値を保存してから、別のパラメーターで再度呼び出したいと考えています。ごく最近、for ループで URL メソッドを呼び出し、 connectionDidFinishLoading:
通知が投稿されたときに NSNotification を投稿し、オブザーバーに NSLogging 値を投稿しようとしました。ただし、最終呼び出しの値を複数回記録するだけです。
これを接続の初期化に使用します...
eventConnection=[[NSURLConnection alloc]initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]] delegate:self startImmediately:NO];
[eventConnection scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[eventConnection start];
これはデリゲートメソッドです...
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSNotification *eventNotification=[NSNotification notificationWithName:@"eventsFound" object:nil userInfo:responseDict];
[[NSNotificationQueue defaultQueue]enqueueNotification:eventNotification postingStyle:NSPostNow coalesceMask:NSNotificationCoalescingOnName forModes:nil];
}
これを達成する方法について何か提案はありますか?