码迷,mamicode.com
首页 > 其他好文 > 详细

How to check if NSString begins with a certain character

时间:2014-07-14 20:51:24      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   for   

How to check if NSString begins with a certain character

How do you check if an NSString begins with a certain character (the character *).

The * is an indicator for the type of the cell, so I need the contents of this NSString without the *, but need to know if the * exists.

You can use the -hasPrefix: method of NSString:

NSString* output = nil;
if([string hasPrefix:@"*"])
    output = [string substringFromIndex:1];

 

How to check if NSString begins with a certain character,布布扣,bubuko.com

How to check if NSString begins with a certain character

标签:style   blog   http   color   os   for   

原文地址:http://www.cnblogs.com/savagemorgan/p/3842672.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!