Iphone 需要使用NSOperationQueue来解析两个不同的NSOperation类
正在尝试解析包含XML数据的两个不同URLIphone 需要使用NSOperationQueue来解析两个不同的NSOperation类,iphone,nsurlconnection,nsxmlparser,nsoperation,nsoperationqueue,Iphone,Nsurlconnection,Nsxmlparser,Nsoperation,Nsoperationqueue,正在尝试解析包含XML数据的两个不同URL static NSString *string1 = @"http://abc.com/abc1.xml"; NSURLRequest *URL1 =[NSURLRequest requestWithURL:[NSURL URLWithString:string1]]; self.URL1Connection =[[[NSURLConnection alloc] initWithRequest:URL1 delegate:self] autorele
static NSString *string1 = @"http://abc.com/abc1.xml";
NSURLRequest *URL1 =[NSURLRequest requestWithURL:[NSURL URLWithString:string1]];
self.URL1Connection =[[[NSURLConnection alloc] initWithRequest:URL1 delegate:self] autorelease];
static NSString *string2 = @"http://abc.com/abc2.xml";
NSURLRequest *URL2 =[NSURLRequest requestWithURL:[NSURL URLWithString:string2]];
self.URL2Connection =[[[NSURLConnection alloc] initWithRequest:URL2 delegate:self] autorelease];
我有两个不同的NSO操作班,都独立工作,因为都有自己的工作要完成。
我有一个parseQueue,它是NSOperationqueue,我在其中添加了两个不同的操作
TestOperation *testOperation = [[TestOperation alloc]
initWithData:self.data1 delegate:self ];
[self.parseQueue addOperation:testOperation];
[testOperation release]; // once added to the NSOperationQueue it's retained, we don't need it anymore
testOperation = nil;
Test1Operation *test1Operation = [[Test1Operation alloc]
initWithData:self.data2];
[self.parseQueue addOperation:test1Operation];
[test1Operation release]; // once added to the NSOperationQueue it's retained, we don't need it anymore
test1Operation = nil;
基本上,我试图分别解析这两个xml数据,并希望有并发操作。但是,当第二个操作结束添加到队列中时,它仍然会查看第一个类操作。我迷失在这一点上,因为我不知道为什么即使在发布后它仍然在寻找第一个类。谁能提出一些想法来帮助我。我找到了答案 需要在各自的类中调用每个XML URL,并分别为每个调用调用调用NSOperation。根据需要调用viewdidload或ViewDidAspect方法,而不是调用应用程序委托方法 解析完成后,通知主线程解析结束并返回结果 西米