Maulik Maulik - 18 days ago 5
iOS Question

how to convert string to array in ios?

I have get a response from server like the following link:

http://paste.ofcode.org/NhBN7HVALRg9DjjucD9xmK

NSString *strdetails = [NSString stringWithFormat:@"%@",[[products objectAtIndex:i] valueForKey:@"details"]];

NSLog(@"%@",strdetails);


string display like following link...when i add on array but it's convert to previous data

http://paste.ofcode.org/35zHDmBWqAERKAJ47V6scJ9

but I want array not string.

please help me.

Answer

Here is your code:

NSString *strdetails = [NSString stringWithFormat:@"%@",[[products objectAtIndex:i] valueForKey:@"details"]];

NSLog(@"%@",strdetails);

I update this code here:

    NSDictionary * dict = [products objectAtIndex:i] valueForKey:@"details"]; // Here you are getting dictionary, Now from this you will get array in this way
// Print this dict
NSLog(@"dict details =  %@",dict);
    NSArray * arrV = dict[@"variants"];
// check your array