#pragma mark---bmob---
[BmobregisterWithAppKey:@"491a56dc15ca8e6e8fad1803f029c908"];
#pragma mark--往GameScore表添加一条数据--
BmobObject*gameScore = [BmobObjectobjectWithClassName:@"GameScore"];
[gameScoresetObject:@"小明"forKey:@"playerName"];
[gameScoresetObject:@78forKey:@"score"];
[gameScoresetObject:[NSNumbernumberWithBool:YES]forKey:@"cheatMode"];
[gameScoresaveInBackgroundWithResultBlock:^(BOOLisSuccessful,NSError*error) {
//进行操作
}];
#pragma mark查找GameScore表
BmobQuery*bquery = [BmobQueryqueryWithClassName:@"GameScore"];
//查找GameScore表里面id为0c6db13c的数据
[bquerygetObjectInBackgroundWithId:@"6899bf70af"block:^(BmobObject*object,NSError*error){
if(error){
//进行错误处理
}else{
//表里有id为0c6db13c的数据
if(object) {
//得到playerName和cheatMode
NSString*playerName =
[objectobjectForKey:@"playerName"];
BOOLcheatMode =
[[objectobjectForKey:@"cheatMode"]boolValue];
NSLog(@"%@----%i",playerName,cheatMode);
}
}
}];
#pragma mark--修改数据--
//查找GameScore表里面id为0c6db13c的数据
[bquerygetObjectInBackgroundWithId:@"6899bf70af"block:^(BmobObject*object,NSError*error){
//没有返回错误
if(!error) {
//对象存在
if(object) {
BmobObject*obj1 = [BmobObjectobjectWithoutDatatWithClassName:object.classNameobjectId:object.objectId];
//设置cheatMode为YES
[obj1setObject:[NSNumbernumberWithBool:NO]forKey:@"cheatMode"];
//异步更新数据
[obj1updateInBackground];
}
}else{
//进行错误处理
}
}];
}