开发者

NSString - how to check if it contains quotation marks <">

[[somestring substringtoindex:0] is equaltostring:@"""]; 'makes red' the rest of the code. actually i can't开发者_运维问答 put quotation marks inside quotation marks. still, this is the character i want to reffer. how should I do it in the correct way? thanks


To escape a character, use the backslash.

@"\"";

And to check if a string exists, use -rangeOfString:.

if ([string rangeOfString:@"\""].location != NSNotFound) { ... }

or -hasPrefix: and -hasSuffix:

if ([string hasPrefix:@"\""]) { ... }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜