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:@"\""]) { ... }
精彩评论