Bmob的初步使用,Bmob使用

來源:互聯網
上載者:User

Bmob的初步使用,Bmob使用
註冊Bmob帳號

在網址欄輸入www.bmob.cn或者在百度輸入Bmob進行搜尋,開啟Bmob官網後,點擊右上方的“註冊”,在跳轉頁面填入你的姓名、郵箱、設定密碼,確認後到你的郵箱啟用Bmob賬戶,你就可以用Bmob輕鬆開發應用


網站後台建立應用

登入帳號進入bmob後台後,點擊後台介面左上方“建立應用”,在彈出框輸入你應用的名稱,然後確認,你就擁有了一個等待開發的應用。


擷取應用密鑰和下載SDK

選擇你要開發的應用,點擊該應用下方對應的“應用密鑰”




匯入後效果如下:


設定應用的BmobKey


一個測試:上傳名字密碼和圖片的一個測試

創一個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) {                }];}

效果:




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.