alekop
alekop

Reputation: 3026

PhoneGap app crashes with "unrecognized selector" error

I have a basic PhoneGap project, 100% auto-generated code. The app starts, and immediately crashes on the second line:

int main(int args, char* argv[]) {
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); // exception
    [pool release];
    return retVal;
}

The exception is [__NSCFString count] unrecognized selector sent to instance. It seems something expected a string, and got a nil instead. Is there some configuration setting I am supposed to set?

Edit: I am using XCode 4.2.1.

Thanks.

Upvotes: 1

Views: 2400

Answers (3)

Ryan Wheale
Ryan Wheale

Reputation: 28410

For me, I rearranged my plugin parameters in javascript but did not reflect those changes in my backend code... which seems like a "no duh" type of thing but a result of a simple oversight. See my answer here for more details.

Upvotes: 0

alekop
alekop

Reputation: 3026

I figured it out. It was my fault.

My app needs to communicate with a Web service, so I changed the ExternalHosts setting in the .plist file to *. The problem was that instead of adding an item to the array, I had changed the type to String. After changing it back to Array, everything started working.

Upvotes: 2

dhaval
dhaval

Reputation: 7659

try with this code:

int main(int args, char* argv[]) {
    //NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); // exception
    //[pool release];
    return retVal;
}

Upvotes: 0

Related Questions