[NSCFString stringValue]: unrecognized selector sent to instance

I'm using this code to query core data and return the value of key, I store the value like this :

 NSString *newName= @"test"; 
 [newShot setValue:newName forKey:@"shotNumber"]; 

and I query like this :

NSManagedObject *mo = [items objectAtIndex:0];  // assuming that array is not empty
  NSString *value = [[mo valueForKey:@"shotNumber"] stringValue];
  NSLog(@"Value : %@",value);

I'm crashing with this message though :

[NSCFString stringValue]: unrecognized selector sent to instance,

does anyone know where that would be coming from ?


  • newName (@"test") is already an NSString. There is no need to call -stringValue to convert it to a string.

    NSString *value = [mo valueForKey:@"shotNumber"];