The Facebook FBConnect fbDialogLogin method on Facebook.m hits EXC_BAD_ACCESS on the FBSessionDelegate object _sessionDelegate


using facebook-facebook-ios-sdk-cf1c2c3, the _sessionDelegate object is freed before my application is moved to the background.

This means that when the application comes to the forefront after the authentication / authorization callback, this method in Facebook.m images calls EXC_BAD_ACCESS:

- (void)fbDialogLogin:(NSString *)token expirationDate:(NSDate *)expirationDate 

The insult line in this method:

  if ([self.sessionDelegate respondsToSelector:@selector(fbDidLogin)]) { [_sessionDelegate fbDidLogin]; } 

I think this is because on Facebook.h, _sessionDelegate is assigned not saved. Therefore, at some point he is released:

 @property(nonatomic, assign) id<FBSessionDelegate> sessionDelegate; 

Changing the save permission fixes the problem:

 @property(nonatomic, retain) id<FBSessionDelegate> sessionDelegate; 

Seems too obvious to me. So I have to miss something!

Any ideas?

Thanks a lot, XJ

+6
source share
3 answers

Changing the delegate to a save method in this case is probably a more stable solution than anything else. However, somewhere your delegate will be released before you want to release him, and you may need to study what might lead to his release earlier. However, if you do this, be sure to edit the Facebook.m dealloc () method to free the delegate

+1
source

I had the same problem with EXC_BAD_ACCESS. I resolved it by deleting another selected instance of rootViewController.

 RootViewController *rootViewController = [[RootViewController alloc] init]; <-------- facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:rootViewController]; 

it should be selected only once.

this means that if you redistribute your rootViewController and clicking / adding it to another viewController, it will save its previous instance.

Hope this helps resolve EXC_BAD_ACCESS.

0
source

In the calling page, you must disable ARC!

0
source

Source: https://habr.com/ru/post/887702/


All Articles