how can I convert string to an array with separator?

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

    This will be the solution if you are dealing with a string:

    NSString *mySstring = @"hai-welcome";
    NSMutableArray *anArray=[[NSMutableArray alloc] initWithArray:[componentsSeparatedByString: @"-"]];
    

    And each word will be stored in respective position from 0-n.

    Try This. :)

提交回复
热议问题