2011-05-19 82 views
0

我得到串这是 字符串* NEWID = @“12390,12391,12392,12394,12394,12395,12396”添加数据串阵列

这是请求发送给我。

我需要从字符串中添加每个id到NSMutableArray或NSMutableDictionary中。

回答

3
NSString *[email protected]"12390,12391,12392,12394,12394,12395,12396"; 
NSMutableArray *arrayIds = [[newID componentsSeparatedByString:@","] mutableCopy]; 
+0

其工作NSArray ..... – 2011-05-19 10:46:13

+0

我们可以做到这一点 NSMutableArray或NSMutableDictionary – 2011-05-19 10:53:44

+0

更新我的答案nsmutablearray – Eimantas 2011-05-19 11:14:19

1

array = [newID componentsSeparatedByString:@“,”];

0

尝试

NSString *[email protected]"12390,12391,12392,12394,12394,12395,12396"; 
NSArray *arrays = [newID componentsSeparatedByString:@","]; 
NSMutableArray *arr = [NSMutableArray arrayWithArray:arrays]; 
0
NSString *[email protected]"12390,12391,12392,12394,12394,12395,12396"; 
NSArray *arrayIds = [newID componentsSeparatedByString:@","]; 
NSString *str1=[arrayIds objectAtIndex:0]; 
NSString *str2=[arrayIds objectAtIndex:1]; 
. 
. 
. 
0

的NSString * NEWID = @ “12390,12391,12392,12394,12394,12395,12396”;

array = [newID componentsSeparatedByString:@“,”];

(如果使用其他方法)[array retain];