0

我正在尝试将我的应用程序与 FBConnect 连接,但每次都会崩溃。它需要所有以前的凭据,然后在登录后崩溃。我需要将其与此连接,以便在登录时我的应用程序应该打开。

我的代码是

- (void)session:(FBSession*)session didLogin:(FBUID)uid {
    NSString* fql = [NSString stringWithFormat:
                 @"select uid,name from user where uid == %lld", self.usersession.uid];
    NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
    [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
    self.post=YES;
    self.usersession =session;
    NSLog(@"User with id %lld logged in.", uid);
    [self getFacebookName];
}

错误

2012-12-31 11:13:16.522 Project[296:11c03] User with id 10000456096786 logged in.
2012-12-31 11:13:16.922 Project[296:11c03] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
** First throw call stack:
(0x17c5052 0x1c58d0a 0x17b1db8 0xa0d5 0x6ed14 0x6f477 0xffea59 0xffce94 0xffdeb7 0xffce4f 0xffcfd5 0xf41f6a 0x20febbd 0x21cb5ea 0x21cb8b5 0x20f5298 0x21cb16b 0x20f5137 0x179997f 0x16fcb73 0x16fc454 0x16fbdb4 0x16fbccb 0x2473879 0x247393e 0x609a9b 0x27c8 0x2725)

如果我在成功登录后输入我的代码session didlogin以进入应用程序。它与同样的事情崩溃......

- (void)session:(FBSession*)session didLogin:(FBUID)uid {


    NSString* fql = [NSString stringWithFormat:
                 @"select uid,name from user where uid == %lld", self.usersession.uid];
    NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
    [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
    self.post=YES;

    self.usersession =session;
    NSLog(@"User with id %lld logged in.", uid);


    AppDelegate *appdelegte =(AppDelegate*)[[UIApplication sharedApplication]delegate];

    [[[appdelegte navigationController] view]removeFromSuperview];

    [[appdelegte window]addSubview:[[appdelegte tabBarController]view]];

    [[appdelegte tabBarController]setSelectedIndex:0];


    [self getFacebookName];
}

- (void)getFacebookName {
NSString* fql = [NSString stringWithFormat:
                 @"select uid,name from user where uid == %lld", self.usersession.uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
self.post=YES;
}
4

0 回答 0