查询列表,返回前20个数据:
//创建BmobQuery实例,指定对应要 *** 作的数据表名称
BmobQuery *query = [BmobQuery queryWithClassName:className];
//按updatedAt进行降序排列
[query orderByDescending:@"updatedAt"];
//返回最多20个结果
query.limit = ;
//执行查询
[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];
}];
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)