1

我有这个:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    NSURL *url = [NSURL URLWithString:@"http://www.xyz.com/ios/responseScript.php"];

    NSError *error = nil;

    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:&error];

    NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];


}

当我打印 dataString 时,它完全显示了我的期望,即

["Bannana","Apple","SomeCheese"]

我想把它处理成 NSMutableArray。我怎样才能做到这一点?

谢谢,

4

1 回答 1

1

试试这个:

NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:returnData options:kNilOptions error:&error];
NSMutableArray *array = [[NSMutableArray alloc] init];
for(NSString *key in dictionary) {
    [array addObject:[dictionary objectForKey:key]];
}
于 2013-02-02T18:03:29.970 回答