在我的應用程序中,我需要調用一個函數,該函數依次調用許多函數。問題是我打電話給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