根据不同的分隔符将String拆分为单独的字符串

时间:2012-04-20 11:14:57

标签: ios nsarray

示例字符串:

NSString * exampleString = 
@""
 "#--- delimiter2 ---"
 "bla,"
 "bla,"
 "bla"
 "#--- delimiter2 ---"
 "yoip,"
 "yoip,"
 "yoip"
 "#--- delimiter3 ---"
 "etc,"
 "etc,"
 "etc,"
 "etc,"
 "etc,"
 "etc,"
 "etc";

我想取一个数组并将其填充为:

[anyArray objectAtIndex:0] = @"bla,bla,bla"

[anyArray objectAtIndex:1] = @"yoip,yoip,yoip"

[anyArray objectAtIndex:2] = @"etc,etc,etc,etc,etc,etc,etc"

如果这是有道理的......

任何帮助将不胜感激:)

由于

1 个答案:

答案 0 :(得分:5)

NSArray *spliArray = [exampleString componentsSeparatedByString:@"delimiter"];