Reputation: 9732
I'm trying to replace a string with another one by using stringByReplacingOccurrencesOfString, but for some reason it's giving me this error:
-[__NSCFNumber length]: unrecognized selector sent to instance 0x6e49ef0 2012-05-14 16:30:49.741 coop[78129:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x6e49ef0'
NSString *_currentGroup;
NSString *location = [current objectForKey:@"location"];
if(_currentGroup != nil)
{
NSLog(@"_currentGroup: %@", _currentGroup);
// OUTPUT: _currentGroup: 92
location = [location stringByReplacingOccurrencesOfString:@"%group_id%" withString:_currentGroup];
}
When I try the following it just works
location = [location stringByReplacingOccurrencesOfString:@"%group_id%" withString:@"anyOtherString"];
Am I still missing something?
Upvotes: 0
Views: 1650
Reputation:
Your "NSString" is actually an NSNumber
. That's what the error is telling you.
Upvotes: 2