0

i got string which is String *newID=@"12390,12391,12392,12394,12394,12395,12396"

this is the request send to me.

I need to add each id from string into NSMutableArray or NSMutableDictionary.

5 Answers 5

3
NSString *newID=@"12390,12391,12392,12394,12394,12395,12396";
NSMutableArray *arrayIds = [[newID componentsSeparatedByString:@","] mutableCopy];
Sign up to request clarification or add additional context in comments.

1 Comment

can we do this for NSMutableArray or NSMutableDictionary
1

array = [newID componentsSeparatedByString:@","];

Comments

0

Try

NSString *newID=@"12390,12391,12392,12394,12394,12395,12396";
NSArray *arrays = [newID componentsSeparatedByString:@","];
NSMutableArray *arr = [NSMutableArray arrayWithArray:arrays];

Comments

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

Comments

0

NSString *newID=@"12390,12391,12392,12394,12394,12395,12396";

array=[newID componentsSeparatedByString:@","];

(if you use another method)[array retain];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.