我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