-[__NSArrayI stringByReplacingOccurrencesOfRegex:withString:]: unrecognized selector sent to instance
Im trying to clean up a json stream and get the error listed above
N开发者_开发技巧SString *traveladvice = [json valueForKeyPath:@"travel_advice_article.travel_advice_sections.body.markup"];
which gets me a stream with lots of javascript regular expressions like \U00a0 which I want to remove. Im using to regexlite to remove.
NSString *regexString = @"U00a0";
NSString *replacementString = @"";
NSString *travelparse1 = nil;
travelparse1 = [travelAdvice stringByReplacingOccurrencesOfRegex:regexString
withString:replacementString];
I understand the error but whats confusing me is that traveladvice is an NSString not an NSArray.
json valueForPath might return an array, not a string. stop in a debugger and do 'po traveladvice' it will show you the actual data.
also, store the result type as 'id' and not NSString* to avoid confusion
精彩评论