NSString to NSArray

//split NSString as NSArray items

NSString *str=@"item 1;item 2;item 3;item 4;last object is item 5";
NSArray *strArray=[str componentsSeparatedByString:@";"];
NSLog(@"%d",[strArray count]);
NSLog(@"%@",[strArray description]);



//Console output is:

2012-01-01 15:54:41.585 SamppleApp[2697:f803] 5
2012-01-01 15:54:41.585 SamppleApp[2697:f803] (
"item 1",
"item 2",
"item 3",
"item 4",
"last object is item 5"
)

No comments:

Post a Comment