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


using facebook-facebook-ios-sdk-cf1c2c3, the _sessionDelegate object is being deallocated before my app is moved to the background.

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 expirationDate:(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

6
задан Max MacLeod 10 May 2011 в 09:30
поделиться