Search code examples
iphoneobjective-ciosdropboxdropbox-api

Iphone App Crashes on Device while establishing a DropBox Session


I have made an app which uses DropBox SDK for iPhone to connect to the users dropbox account and upload files. I am using XCode 3.2.5 and the iPhone Simulator is 4.2. My application works great on the simulator, but it crashes when I try it on the device. The following is the line of code where it crashes

DBSession* dbSession = [[[DBSession alloc] 
                                 initWithAppKey:kDropBoxAppKey 
                                 appSecret:kDropBoxAppSecret 
                                 root:kDBRootAppFolder] autorelease];

When I tried to debug, it could not recognize the object kDBRootAppFolder.

I checked out where this variable was defined, and it was located inside a file of the DropBox SDK called "DBSession.h" as

extern NSString *kDBRootAppFolder;

While I tried to debug and run it, I found that it showed kDBRootAppFolder was of unknown type.

Then, I tried debugging on the simulator, where it ran perfectly, there the value of kDBRootAppFolder when I printed it was 'sandbox'.

I really dont know why this runtime error is occurring in the device. Please help.


Solution

  • That usually happens when object is released at bad time.

    Try this, note the retain in kDBRootAppFolder

    DBSession* dbSession = [[[DBSession alloc] 
                                     initWithAppKey:kDropBoxAppKey 
                                     appSecret:kDropBoxAppSecret 
                                     root:[kDBRootAppFolder retain]] autorelease];
    

    if it doesn´t work, use NSLog(@"%@", kDBRootAppFolder); before and after the initiation of dbSession to check if is correctly defined.