Bmob 之 列表查询
查询列表,返回前20个数据:
//创建BmobQuery实例,指定对应要操作的数据表名称 BmobQuery *query = [BmobQuery queryWithClassName:className]; //按updatedAt进行降序排列 [query orderByDescending:@"updatedAt"]; //返回最多20个结果 query.limit = 20; //执行查询 [query findObjectsInBackgroundWithBlock:^(NSArray *array, NSError *error) { //处理查询结果 for (BmobObject *obj in array) { News *info = [[News alloc] init]; if ([obj objectForKey:@"title"]) { info.title = [obj objectForKey:@"title"]; } if ([obj objectForKey:@"describe"]) { info.content = [obj objectForKey:@"describe"]; } if ([obj objectForKey:@"phone"]) { info.phoneNum = [obj objectForKey:@"phone"]; } info.time = [_dateFormatter stringFromDate:obj.updatedAt]; [_infoMutableArray addObject:info]; } [_tableView reloadData]; }];