标签:
在网址栏输入www.bmob.cn或者在百度输入Bmob进行搜索,打开Bmob官网后,点击右上角的“注册”,在跳转页面填入你的姓名、邮箱、设置密码,确认后到你的邮箱激活Bmob账户,你就可以用Bmob轻松开发应用
登录账号进入bmob后台后,点击后台界面左上角“创建应用”,在弹出框输入你应用的名称,然后确认,你就拥有了一个等待开发的应用。
选择你要开发的应用,点击该应用下方对应的“应用密钥”
导入后效果如下:
创一个button 关联事件:
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; [button setTitle:@"发送" forState:UIControlStateNormal]; button.bounds = CGRectMake(0, 0, 200, 30); button.center = self.view.center; [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button];
- (void)buttonPressed:(UIButton *)sender { [self createBmobObject]; // [self addUserInfo]; }
-(void)createBmobObject{ //往GameScore表添加一条playerName为小明,分数为78的数据 BmobObject *gameScore = [BmobObject objectWithClassName:@"UserInformation"]; [gameScore setObject:@"你的名字" forKey:@"name"]; [gameScore setObject:@"123" forKey:@"password"]; [gameScore saveInBackgroundWithResultBlock:^(BOOL isSuccessful, NSError *error) { if (isSuccessful) { NSLog(@"成功"); }else { NSLog(@"失败"); } }]; NSBundle *bundle = [NSBundle mainBundle]; //本地图片 NSString *fileString = [NSString stringWithFormat:@"%@/image1.jpg" ,[bundle bundlePath] ]; BmobFile *file = [[BmobFile alloc] initWithFilePath:fileString]; [file saveInBackground:^(BOOL isSuccessful, NSError *error) { if (isSuccessful) { [gameScore setObject:file forKey:@"logImage"]; [gameScore updateInBackground]; NSLog(@"成功"); } } withProgressBlock:^(float progress) { }]; }
标签:
原文地址:http://blog.csdn.net/u011032334/article/details/42917457