One, code.
-(void) viewdidload{ [Super Viewdidload]; Do any additional setup after loading the view. [Email protected] "string segmentation"; Parsing of the general string nsstring *string = @ "One,two,three,four"; NSLog (@ "string:%@", string); Nsarray *array = [string componentsseparatedbystring:@ ","]; NSLog (@ "array:%@", array); Two JSON arrays joined together parsing nsstring *jsonstringother=[nsstring stringwithformat:@ "{\" name\ ": \" Li hua \ ", \" sex\ ": \" female \ ", \" Age\ ": \" 20\ "}\n{\" name\ ": \" Li hua \ "," sex\ ": \" female \ ", \" age\ ": \" 20\ "}"; NSLog (@ "-----jsonstringother---%@", jsonstringother); Nsarray *jsonarray = [Jsonstringother componentsseparatedbystring:@ "\ n"]; NSLog (@ "jsonarray:%@", Jsonarray); }
Two, output.
2015-10-22 11:13:21.872 string Segmentation [4057:112931] string:one,two,three,four2015-10-22 11:13:21.873 string segmentation [4,057:112,931] Array: (one , three, four ) 2015-10-22 11:13:21.873 string segmentation [4057:112931]-----jsonstringother--- {"name": "Li Hua", "Sex": "Female", "Age": "20"} {"name": "Li Hua", "Sex": "Female", "Age": "20"}2015-10-22 11:13:21.873 string segmentation [4057:112931] Jsonarray: ( "{\" name\ ": \" \u674e \u534e\ ", \" sex\ ": \" \u5973\ ", \" age\ ": \" 20\ "}", "{\" name\ ": \" \u674e\u534e\ ", \" sex\ ": \" \u5973\ ", \" age\ ": \" 20\ " }")
Segmentation of the "code note" string