Facebook FBConnect fbDialogLogin method in Facebook.m hits EXC_BAD_ACCESS on FBSessionDelegate object _sessionDelegate
This means when the app comes to the foreground after the authentication/authorization callback, this method in Facebook.m hits causes a EXC_BAD_ACCESS:
- (void)fbDialogLogin:(NSString *)token exp开发者_运维知识库irationDate:(NSDate *)expirationDate
The offending line in that method being this one:
if ([self.sessionDelegate respondsToSelector:@selector(fbDidLogin)]) {
[_sessionDelegate fbDidLogin];
}
I think this is because in Facebook.h, _sessionDelegate is being assigned not retained. Therefore at some point it is deallocated:
@property(nonatomic, assign) id<FBSessionDelegate> sessionDelegate;
Changing it to retain appears to resolve the problem:
@property(nonatomic, retain) id<FBSessionDelegate> sessionDelegate;
Seems like too obvious a thing to me. Therefore I must be missing something!
Any ideas?
Many thanks, xj
Changing the delegate to a retain method in this case is probably a more stable solution than anything else. However somewhere your delegate is being released before you want it to be released and you may need to look into what would cause it to be released early. However if you do this make sure you edit the Facebook.m dealloc() method to release your delegate
I had same EXC_BAD_ACCESS problem.i resolved it by removing other allocated instance of rootViewController.
RootViewController *rootViewController = [[RootViewController alloc] init]; <--------
facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:rootViewController];
it should be allocated only once.
that means if you are again allocating your rootViewController and pushing/adding it another viewController it retains its previous instance.
Hope it helps to resolve EXC_BAD_ACCESS.
In calling page you must disable ARC!
精彩评论