Facebook-Ios-Sdk 3.0.8在替代login时崩溃Xcode

我正在使用Facebook-ios-sdk 3.0.8login我的应用程序。 它在第一次罚款,给我的UsernameFbGraph但它崩溃的Xcode在我的下一个login…什么原因…请检查代码,让我知道…

 - (IBAction)buttonClickHandler:(id)sender { // get the app delegate so that we can access the session property AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; // this button's job is to flip-flop the session from open to closed if (appDelegate.session.isOpen) { [appDelegate.session closeAndClearTokenInformation]; } else { if (appDelegate.session.state != FBSessionStateCreated) { appDelegate.session = [[FBSession alloc] init]; } [FBSession.activeSession openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { // and here we make sure to update our UX according to the new session state [self updateView]; NSLog(@" state=%d",state); [FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id<FBGraphUser> user, NSError *error) { userInfo = @""; // Example: typed access (name) // - no special permissions required userInfo = user.username; NSLog(@"string %@", userInfo); }]; }]; } } 

首先login输出

 2013-01-16 13:56:35.613 facebooktest[2690:f803] state=513 2013-01-16 13:56:36.335 facebooktest[2690:f803] string christien.101012 

在下次login时输出

  2013-01-16 13:56:42.747 facebooktest[2690:f803] *** Terminating app due to uncaught exception 'com.facebook.sdk:InvalidOperationException', reason: 'FBSession: an attempt was made to open an already opened or closed session' *** First throw call stack: (0x15ca052 0x175bd0a 0x15c9f11 0x1249f 0x3043 0x15cbec9 0x11b5c2 0x11b55a 0x1c0b76 0x1c103f 0x1c02fe 0x140a30 0x140c56 0x127384 0x11aaa9 0x14b4fa9 0x159e1c5 0x1503022 0x150190a 0x1500db4 0x1500ccb 0x14b3879 0x14b393e 0x118a9b 0x1e38 0x1d95 0x1) 

和**会有什么区别**

 [FBSession.activeSession openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState state, NSError *error) 

  [appDelegate.session openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState state, NSError *error) 

在简单的话FBSession.activeSessionFBSession.activeSession因为如果我使用FBSession.activeSession ,而不是它不给我的user.username而不是崩溃…我使用FBSession.activeSession它给了我的user.username第一次然后下次崩溃..