Here is a simple code that does this..
-(NSMutableArray *) getAnswers :(NSString *) yourstring{ NSMutableArray *answers = [NSMutableArray new ]; NSArray *parts = [[yourstring componentsSeparatedByString:@ "," ]; for (NSString *str in parts){ [answers addObject:str]; } NSLog(@ "RET answers %@" , answers); return answers; } |
After splitting the string with “componentsSeparatedByString” the parts are added to a NSMutableArray using addObject.