我正在使用 NSArray 并将我使用 json_encode
检索到的字符串放入其中
当它是纯文本时它可以工作,但如果它喜欢我的图像并给我这个错误则不工作
我也试过使用 NSMutableArray 但同样的问题,所以如果问题来自这些 "\r\n".. 等,如何将其转换为纯文本?
这是我使用的代码:
NSError *er;
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:8888/ost.php"]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *json_string = [[NSString alloc]initWithData:response encoding:NSUTF8StringEncoding];
content = [parser objectWithString:json_string error:&er];
NSLog(@"%@",json_string);
NSLog(@"%d",[content count]);
NSLog(@"%@",[content objectAtIndex:0]);
最佳答案
我看到一个 NSDictinoary 错误,它使用 objectForKey
而不是 objectAtIndex
您的问题可能是:
NSLog(@"%@",[content objectAtIndex:0]);
检查 content
的类型这可能是一个字典,被要求提供索引处的对象。
关于php - NSArray 无法识别我放入其中的内容并给我错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11263642/