1

我调用 Web 服务,传递一个参数,然后在 viewcontroller 类中注册一个观察者(以通知下载完成):

[self callWebservice:parameter1];
[[NSNotificationCenter defaultCenter] addObserver:self    selector:@selector(dataDownloadComplete:) name:OP_DataComplete object:nil];

然后在我的解析器类中发布通知:

-(void)connectionDidFinishLoading:(NSURLConnection *)connection method of the parser  class. [[NSNotificationCenter defaultCenter] postNotificationName:OP_DataComplete object:nil];

在回调方法 dataDownloadComplete: 我想多次调用同一个 Web 服务。

-(void)dataDownloadComplete
{
 if([anArray objectAtindex:N]<10)
  {
   [self callWebservice:parameterN];
   NSLog(@"This is getting called everytime (9 times)");
   [self writeintoDatabase];
   N++;
  }
}

但问题是我想将我从服务下载的数据写入数据库。数据库写入奇怪地发生在“parameter1”调用中,并且为其他调用继续,但不是为parameter9(我也需要)。请注意,日志被调用了 9 次。writeintoDatabase 代码是完美的。请帮忙。提前致谢。

4

0 回答 0