开发者

-[__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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜