Michael Nana
Michael Nana

Reputation: 1977

__NSCFConstantString objectForKey unrecognized selector sent to instance error

I basically get this error

'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x581f0'

on my program. I think it refers to this call I make,

if (data != nil) {
    if([data objectForKey:@"username"]){
       // NSArray *check= [[NSArray alloc]init];
        //check=[data allValues];
        [dict setObject:[data allValues] forKey:@"args"];

    }else{
    [dict setObject:[NSArray arrayWithObject:data] forKey:@"args"];
}

at the setObject:[data allValues]. I don't know why it gives that error but data is an NSDictionary and I'm getting all the values and placing it in an array.

Upvotes: 3

Views: 4439

Answers (1)

D.C.
D.C.

Reputation: 15588

Is the error happening here:

    if([data objectForKey:@"username"]){

I assume so, as that is the only place objectForKey seems to be called. You are calling it on a variable called 'data', which i'm guessing simply is not a dictionary. You should NSLog its type to see.

Upvotes: 3

Related Questions