2012-04-20 78 views
1

例字符串:拆分一個NSString成單獨的字符串根據不同的分隔符

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" 

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

任何幫助,將不勝感激:)

謝謝

回答

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

然後我有「# - 」作爲sp​​liArray中的元素之一......但是我弄清楚了我必須做的事情。 – 2012-04-28 10:23:17

+0

@NathanielRogers你能讓我知道你想出了什麼嗎? – Deepukjayan 2013-07-30 06:28:53

相關問題