Facebook sdk iOS logout error

I'm currently working with the new Facebook SDK and I have a very strange problem. I have a viewcontroller, called FacebookExplorerTableViewController and in my viewdidload I have the following piece of code:

if(appDelegate.session.isOpen)
    {
        [self receiveAlbums];
    }
    else 
    {
        appDelegate.session = [[FBSession alloc] init];

        appDelegate.session = [FBSession sessionOpenWithPermissions:nil completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
            NSLog(@"opened session");
            if(!error) [self receiveAlbums];
            else NSLog(@"error: %@",error);
        }];
}

When I'm running it, everything's fine. However, I have another viewcontroller, named SharingSettingsTableViewController where I have the option to logout:

[appDelegate.session closeAndClearTokenInformation];

When I'm trying to logout, I get a xCode crash:

2012-08-09 21:29:19.683 My Albums[2197:17903] opened session
2012-08-09 21:29:19.684 My Albums[2197:17903] requesting albums
2012-08-09 21:29:19.695 My Albums[2197:17903] access token: (null)
2012-08-09 21:29:19.697 My Albums[2197:17903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x1b6d022 0x1f56cd6 0x1aac7db 0x1ac4e86 0x757a5 0x754f4 0xa17e2 0x9ef39 0x676f9 0x92c3f1 0x1b6ee99 0x55514e 0x5550e6 0x5fbade 0x5fbfa7 0x5fb266 0x57a3c0 0x57a5e6 0x560dc4 0x554634 0x232eef5 0x1b41195 0x1aa5ff2 0x1aa48da 0x1aa3d84 0x1aa3c9b 0x232d7d8 0x232d88a 0x552626 0x21ed 0x2155)
terminate called throwing an exception

It seems to run my completion block again! The 'requesting albums' in the console is coming from the call to receiveAlbums.

Why does this completion block run again? At the time I go to the Settings view controller, I've already deallocated the FacebookExplorerTableViewController! How can this run and how could I get rid of the error? :)

Thanks in advance!

Answers


I've had the same issue. My problem was retaining [FBSession activeSession].accessToken by passing it into a NSDictionary. The easiest solution was to pass a [NSString stringWithFormat:@"%@", [FBSession activeSession].accessToken] instead of straight [FBSession activeSession].accessToken usage.


Need Your Help

Python multiprocessing design

python iteration multiprocessing gdal

I have written an algorithm that takes geospatial data and performs a number of steps. The input data are a shapefile of polygons and covariate rasters for a large raster study area (~150 million p...

Retrieve attributes from object

objective-c sqlite3

I'm pretty much brand new to Xcode. I'm trying to retrieve information on an artist from a sqlite3 database. The following is where I insert the artist: