Initial use of Bmob and use of Bmob
Register a Bmob account
Enter www.bmob.cn in the URL bar or enter Bmob in Baidu for search. Open the Bmob official website and click "register" in the upper right corner. enter your name, email address, and password on the jump page, after confirmation, activate your Bmob account in your mailbox, and you can use Bmob to easily develop applications.
Create an application on the website background
Log on to the bmob background, click "create application" in the upper-left corner of the background interface, enter the name of your application in the pop-up box, and then confirm that you have an application waiting for development.
Get app key and download SDK
Select the application you want to develop and click the corresponding "application key" below the application"
After the import, the results are as follows:
Set BmobKey of the application
One test: one test for uploading name, password, and image
Create a button Association event:
UIButton * button = [UIButton buttonWithType: UIButtonTypeSystem]; [button setTitle: @ "send" 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 {// Add a playerName for the GameScore table BmobObject * gameScore = [BmobObject objectWithClassName: @ "UserInformation"]; [gameScore setObject: @ "Your name" forKey: @ "name"]; [gameScore setObject: @ "123" forKey: @ "password"]; [gameScore saveInBackgroundWithResultBlock: ^ (BOOL isSuccessful, NSError * error) {if (isSuccessful) {NSLog (@ "success");} else {NSLog (@ "failed") ;}}]; NSBundle * bundle = [NSBundle mainBundle]; // NSString * fileString = [NSString stringWithFormat: @ "% @/image1.jpg", [bundle bundlePath]; bmobFile * file = [[BmobFile alloc] initWithFilePath: fileString]; [file saveInBackground: ^ (BOOL failed, NSError * error) {if (isSuccessful) {[gameScore setObject: file forKey: @ "logImage"]; [gameScore updateInBackground]; NSLog (@ "successful") ;}} withProgressBlock: ^ (float progress) {}];}
Effect: