これがあなたがする必要があることです。これは、NSURLConnection API を使用して非同期リクエストを作成する方法と非常によく似ています。
header/.h ファイルでクラス属性を作成します (メンバー変数、呼びたいものは何でも)
//header/.h file
int indexOfLastFriendLoaded;
実装ファイルで:
- (void) loadFriend:(int) indexOfFriendToLoad {
[facebook requestWithGraphPath:[self.friendIDArray objectAtIndex:indexOfFriendToLoad] andDelegate:self];
}
//this method is called when each facebook request finishes,
- (void)request:(FBRequest *)request didLoad:(id)result {
//first do whatever you need to with "result" to save the loaded friend data
//We make the next request from this method since we know the prior has already completed.
if (indexOfLastFriendLoaded < [self.friendIDArray count]) {
[self loadFriend:indexOfLastFriendLoaded];
indexOfLastFriendLoaded++;
}
}
- (void) viewDidLoad {
//initialize facebook object first
indexOfLastFriendLoaded = 0;
[self loadFriend:indexOfLastFriendLoaded];
}