Facebook-ios-sdk 3.0.8
アプリにログインするために使用しています。初めて正常に動作し、次のログインでXcodeがクラッシュUsername
しFbGraph
ます..理由は何ですか...コードを確認して教えてください...
- (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);
}];
}]; }
}
最初のログイン出力
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
次のログイン時の出力の下
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)
簡単に言えばappDelegate.session
、その代わりにFBSession.activeSession
使用すると、クラッシュせず、クラッシュしないためです...そして、それを使用すると、初めてクラッシュし、次にクラッシュします..appDelegate.session
user.username
FBSession.activeSession
user.username