iphone - Convert NSString into NSMutableArray (specific String) -
i have string
test string =====>{"name":"0","age":"0","sex":"0","weight":"0"}
want string array of type:
myarray[0]="name"; myarray[1]="age"; myarray[2]="sex"; myarray[3]="weight";
please idea crack thing.. in advance.
try
nsarray *arrcomponents = [str componentsseparatedbystring:@","]; nsmutablearray *arrmfilter = [[nsmutablearray alloc] init]; for(int = 0; < [arrcomponents count] ;i++) { nsstring *str = [arrcomponents objectatindex:i]; str = [str stringbyreplacingoccurrencesofstring:@":" withstring:@""]; str = [str stringbyreplacingoccurrencesofstring:@"\"" withstring:@""]; str = [str stringbyreplacingoccurrencesofstring:@"{" withstring:@""]; str = [str stringbyreplacingoccurrencesofstring:@"}" withstring:@""]; str = [str stringbyreplacingoccurrencesofstring:@"0" withstring:@""]; [arrmfilter addobject:str]; } nslog(@"filtered array = %@", arrmfilter);
Comments
Post a Comment