我experiancing下一個問題:RequestDidLoad不會被調用
我有3類,從Facebook的API獲取數據,並通過委派進行通信。第一堂課帶我的朋友,然後爲每個朋友第二堂課調用朋友的活動,返回他們,然後爲每個朋友的活動,第三類調用活動的ID來獲得完整的活動信息。這是問題出現的地方,在調用3rd類之後,fb請求api得到執行(requestLoading函數開始),但它不會在該類中等待得到答覆,而是跳出該類。
下面是代碼:
// Class 1:
// calling friends in first class
- (void) callFriendData
{
PicShowAppDelegate* appDelegate = (PicShowAppDelegate*)[[UIApplication sharedApplication] delegate];
Facebook *facebook = appDelegate.facebook;
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
}
// receiving friends + calling friend class for each friend in which we will call events
- (void)request:(FBRequest *)request didLoad:(id)result {
NSMutableArray *data = [result objectForKey:@"data"];
NSMutableArray *tmpFriendID = [data valueForKey:@"id"];
NSMutableArray *tmpFriendName = [data valueForKey:@"name"];
for(int i=0;i<[tmpFriendID count];i++)
{
FBFriend *fbFriend = [[FBFriend alloc]init];
[fbFriend setDelegate:self];
fbFriend.friendID = [tmpFriendID objectAtIndex:i];
fbFriend.friendName = [tmpFriendName objectAtIndex:i];
[fbFriend takeEvents];
[friendDataArray addObject:fbFriend];
[fbFriend release];
}
}
// class 2, friend, here I call events
- (void) takeEvents
{
PicShowAppDelegate* appDelegate = (PicShowAppDelegate*)[[UIApplication sharedApplication] delegate];
Facebook *facebook = appDelegate.facebook;
[facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/events",self.friendID] andDelegate:self];
}
// receiving events for certain user
- (void)request:(FBRequest *)request didLoad:(id)result {
....
// sending events back to 1st class
[[self delegate] eventsTaken:eventIDs fromFriendID:self.friendID];
}
// first class receives events for certain user, saves it to array of
//user's events and then calls 3rd class for each event in array, to get full info
- (void) eventsTaken: (NSArray *)idEvents fromFriendID: (NSString*) idFrenda
{
for(int i=0;i<[friendDataArray count];i++)
if([[[friendDataArray objectAtIndex:i] valueForKey:@"friendID"] isEqual:idFrenda])
for(int j=0;j<[idEvents count];j++)
{
Event *event = [[Event alloc] init];
event.eventID=[idEvents objectAtIndex:j];
[event takeEvent];
[event release];
}
}
// 3rd class, event
-(void) takeEvent
{
PicShowAppDelegate* appDelegate = (PicShowAppDelegate*)[[UIApplication sharedApplication] delegate];
Facebook *facebook = appDelegate.facebook;
[facebook requestWithGraphPath:[NSString stringWithFormat:@"%@",self.eventID] andDelegate:self];
}
// this never gets called
- (void)request:(FBRequest *)request didLoad:(id)result {
....
}
沒有線索,任何人? – kikovi