how can I convert string to an array with separator?

后端 未结 12 1936
故里飘歌
故里飘歌 2020-12-09 07:26

I have a string in the following format

myString = \"cat+dog+cow\"

I need to store each string separated by + in to a array. Eg:



        
12条回答
  •  感情败类
    2020-12-09 07:48

    Try This:

    NSString *str = @"cat+dog+cow" ;
    NSArray *array = [str componentsSeparatedByString:@"+"];
    NSLog(@"%@",array) ;
    

提交回复
热议问题