I have a method as follows use to correct empty values in Json
+(NSString *)CorrectJsonForEmptyValues:(NSString *)pasRawJson
{
NSLog(@"CorrectJsonForEmptyValues");
NSMutableString *tmpJson = [pasRawJson mutableCopy];
[tmpJson replaceOccurrencesOfString:@"[,"
withString:@"[{\"v\": \"N/A\",\"f\":\"N/A\"},"
options:0
range:NSMakeRange(0, [tmpJson length])];
[tmpJson replaceOccurrencesOfString:@",,"
withString:@",{\"v\": \"N/A\",\"f\":\"N/A\"},"
options:0
range:NSMakeRange(0, [tmpJson length])];
NSString *correctedJson=tmpJson;
return correctedJson;
}
Called the function like this
result = [self performSelector:@selector(CorrectJsonforEmptyvalues:) withObject:result];
But getting error
2011-11-11 11:11:33.217 HelloWorld10[38833:207] -[Data CorrectJsonforEmptyvalues:]: unrecognized selector sent to instance 0x5725cc0
2011-11-11 11:11:33.219 HelloWorld10[38833:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Data CorrectJsonforEmptyvalues:]: unrecognized selector sent to instance 0x5725cc0'
If any one can please provide a solution it will be helpful.
Thanks in advance.
You have declared
CorrectJsonForEmptyValues:as a class method by starting its declaration/definition with a+instead of a-. Therefore you call it on the class object, not on an instance of the class. If your class is namedData, for example, you call it like this:By the way, you should not start method names with capital letters.