how can I convert string to an array with separator?

后端 未结 12 1935
故里飘歌
故里飘歌 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:55

    Try this..

    NSArray *arr = [myString componentsSeparatedByString:@"-"];
    
    [arr objectAtIndex:0];//Hai
    [arr objectAtIndex:1];//Welcome
    

提交回复
热议问题