제 애플리케이션에서 함수를 호출해야합니다. 함수를 호출하면 여러 함수가 호출됩니다. 문제는 getweather
함수를 호출하고 startprocess
을 시작한 후 프로세스가 완료된 것입니다. processCompleted
메서드는 rssparser
에 의해 호출되며 값은 processCompleted
메서드 끝에서 사용할 수 있습니다. 나는 getWeather
기능이라고 때문에함수가 값을 반환하기를 기다리는 중
-(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
메소드에 의해 반환되는 값을받을 수 있나요. 다만 어떤 구조화 된 언어로 같은 목적 C에서
질문이있는 경우 편집하십시오. 그것을 확인하십시오. –
내 대답은 동일하게 유지됩니다. 선택기 나 백그라운드 스레드를 사용하지 않으므로 항상 읽으십시오. 반환 값은 항상 얻어 지므로 함수를 동기화 할 필요가 없습니다. –