开发者

How to find delimiter in objective C?

I have a string :

NSString *s = @"a+v+c+d";

Where '+'开发者_JAVA技巧 is the delimiter.

I want to store each a,b,c,d in array. How can it be done in objective C?


- (NSArray *)componentsSeparatedByString:(NSString *)separator

is the method you are looking for

NSArray *yourArray = [yourString componentsSeparatedByString:@"+"];


-[NSString componentsSeparatedByString:] returns a, v, c, d as elements in an NSArray. Use -[NSString componentsSeparatedByCharactersInSet:] if you have more than one delimiter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜