私のアプリケーションでは、多くの関数を呼び出す関数を呼び出す必要があります。問題は私がgetweather
関数を呼び出すことであり、startprocess
を開始し、その後処理が完了します。 processCompleted
メソッドはrssparser
によって呼び出され、値はprocessCompleted
メソッドの最後で使用できます。私はgetWeather
関数を呼び出しているので、私は、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]);
}
。ちょうどあなたが関数が値を返すまで
NSInteger x = [self yourFunction];
[self somethingElse:x];
に次の命令が実行されていないように値を返す関数を呼び出す任意の構造化言語、のように客観的Cでは
質問を編集している場合。これをチェックしてください。 –
私の答えは変わっていませんが、セレクタやバックグラウンドスレッドを使用していないので、返された値は常に取得され、機能を同期させる必要はありません。 –