#pragma mark---bmob---
[BmobregisterWithAppKey:@"491a56dc15ca8e6e8fad1803f029c908"];
#pragma mark--往GameScore表添加一條數(shù)據(jù)--
BmobObject*gameScore = [BmobObjectobjectWithClassName:@"GameScore"];
[gameScoresetObject:@"小明"forKey:@"playerName"];
[gameScoresetObject:@78forKey:@"score"];
[gameScoresetObject:[NSNumbernumberWithBool:YES]forKey:@"cheatMode"];
[gameScoresaveInBackgroundWithResultBlock:^(BOOLisSuccessful,NSError*error) {
//進(jìn)行操作
}];
#pragma mark查找GameScore表
BmobQuery*bquery = [BmobQueryqueryWithClassName:@"GameScore"];
//查找GameScore表里面id為0c6db13c的數(shù)據(jù)
[bquerygetObjectInBackgroundWithId:@"6899bf70af"block:^(BmobObject*object,NSError*error){
if(error){
//進(jìn)行錯(cuò)誤處理
}else{
//表里有id為0c6db13c的數(shù)據(jù)
if(object) {
//得到playerName和cheatMode
NSString*playerName =
[objectobjectForKey:@"playerName"];
BOOLcheatMode =
[[objectobjectForKey:@"cheatMode"]boolValue];
NSLog(@"%@----%i",playerName,cheatMode);
}
}
}];
#pragma mark--修改數(shù)據(jù)--
//查找GameScore表里面id為0c6db13c的數(shù)據(jù)
[bquerygetObjectInBackgroundWithId:@"6899bf70af"block:^(BmobObject*object,NSError*error){
//沒(méi)有返回錯(cuò)誤
if(!error) {
//對(duì)象存在
if(object) {
BmobObject*obj1 = [BmobObjectobjectWithoutDatatWithClassName:object.classNameobjectId:object.objectId];
//設(shè)置cheatMode為YES
[obj1setObject:[NSNumbernumberWithBool:NO]forKey:@"cheatMode"];
//異步更新數(shù)據(jù)
[obj1updateInBackground];
}
}else{
//進(jìn)行錯(cuò)誤處理
}
}];
}