在我的应用程序中,我需要调用一个函数,该函数依次调用许多函数。问题是我打电话给getweather
函数,它启动startprocess
,然后过程完成。 processCompleted
方法由rssparser
调用,该值在processCompleted
方法的末尾可用。等待函数返回值
-(void) getWeather: (NSDictionary *) dictionary {
_rssParser = [[BlogRssParser alloc]init];
self.rssParser.address = addressInterestedIn;
self.rssParser.delegate = self;
[[self rssParser]startProcess];
}
//Delegate method for blog parser will get fired when the process is completed
-(void)processCompleted
{
NSLog(@"the rssItems array is %@", [[[self rssParser]rssItems] description]);
int woeid = [[[[self rssParser] rssItems] objectAtIndex:0] intValue];
// get weather update from yahoo
NSLog(@"temperature option %d", [[[NSUserDefaults standardUserDefaults] objectForKey:@"temperature"] intValue]);
SCYahooWeatherParser *parser = [[SCYahooWeatherParser alloc] initWithWOEID:woeid weatherUnit: [[[NSUserDefaults standardUserDefaults] objectForKey:@"temperature"] intValue]];
//parse the returned xml from yahoo
SCWeather *result = [parser parse];
[parser release];
NSLog(@"the conditionDataDict is %@", [result.conditionDataDict description]);
}
如何获得由processCompleted
方法的返回值,因为我已经叫getWeather
功能。
是否已编辑该问题。请检查一下。 – 2012-04-16 09:46:21
我的答案保持不变,请仔细阅读,您没有使用任何选择器或后台线程,因此总是获取返回的值,无需同步这些函数。 – 2012-04-16 13:52:11