首页 > 代码库 > 字符串的分割

字符串的分割

 

 

 

 //一般的字符串的解析

    NSString *string = @"One,Two,Three,Four";

    NSLog(@"string:%@",string);

    NSArray *array = [string componentsSeparatedByString:@","];

    NSLog(@"array:%@",array);

   

    

    //两个json数组连在一起的解析

    NSString *jsonStringOther=[NSString stringWithFormat:@"{\"name\":\"李华\", \"sex\":\"女\", \"age\":\"20\" }\n{\"name\":\"李华\", \"sex\":\"女\", \"age\":\"20\" }"];

    NSLog(@"-----jsonStringOther---%@",jsonStringOther);

    NSArray *jsonArray = [jsonStringOther componentsSeparatedByString:@"\n"];

    NSLog(@"jsonArray:%@",jsonArray);