我是 ios 开发的新手,我想从数据库中添加一些对象,我设法将其放入 a 中NSMutabledictionary
,并且我想放入 aNSMutableArray
中以显示在 a 中UITableView
。下面是我的 .m 文件代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
jsonURL = [NSURL URLWithString:@"http://localhost:8888/read_product_list.php"];
//jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL];
NSData *data = [NSData dataWithContentsOfURL:jsonURL];
[self getData:data];
}
-(void) getData:(NSData *) response {
NSError *error;
NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:response options:kNilOptions error:&error];
//NSLog(@"%@", json);
jsonArray = [[NSMutableArray alloc] init];
/*for(int i = 0; i < json.count; i++){
[jsonArray addObject:[json objectForKey:];
}*/
//NSLog(@"%@", jsonArray);
}
先感谢您!