Introduce a,

Bmob back-end cloud provides a visual cloud data table design interface, easy to build databases and tables. Supports 10 different data types: string, integer, array, etc.

The statement is not an advertisement for the service, but an introduction to its use

Two, simple use

  1. To register a Bmob account, enter www.bmob.cn in the url bar or enter Bmob in Baidu to search. Open the Bmob official website, click “Register” in the upper right corner, and enter your name, email, and password on the jump page. After confirming, go to your email to activate the Bmob account, and you can easily develop applications with Bmob.

  2. After entering 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 to be developed.

  3. Select the app you want to develop and enter the app

On the jump page, enter The Settings/Application key and click Copy to obtain the Application ID

After obtaining the Application ID, download the SDK. Developers can select the corresponding iOS SDK or Android SDK according to their own requirements and click download.

Iii. SDK integration on iOS

  1. Download the SDK directly and import it into the project
  • Add BmobSDK to your project: Add BmobSDK. Framework to your XCode project

  • Add the system framework used:

Introduce Project ->TARGETS -> Build Phases->Link Binary With Libraries in your XCode Project CoreLocation framework, Security) framework, CoreGraphics) framework, MobileCoreServices. The framework, CFNetwork. Framework, CoreTe Lephony framework, SystemConfiguration framework, libz. 1.2.5. TBD, libicucore. TBD, libsqlite3. TBD, libc++. TBD, photos. The framework

  1. Import via Pods, inPodfilewrites
Platform :ios,'9.0' target 'BmopDataDemo' do pod 'BmobSDK' endCopy the code

Then run the Pod install command to install it

4. Simple use of iOS

  1. Create an Application Key in the appdelegate. m file of your XCode project and fill in the requested authorization Key (the SDK uses the Application ID from the Application Key) as shown in the following example:

You need to create a table in the Bmob console before you can perform operations on it

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [Bmob RegisterWithAppKey :@" Application ID"]; return YES; }Copy the code
  1. Add a piece of data
BmobObject *gameScore = [BmobObject objectWithClassName:@"Customer"]; [gameScore setObject:@" @" forKey:@"UserName"]; [gameScore setObject:@"1993-07-22" forKey:@"UserBirthDay"]; [gameScore setObject:@YES forKey:@"Sex"]; [gameScore saveInBackgroundWithResultBlock:^(BOOL isSuccessful, If (isSuccessful) {self.userId = gamescore.objectid; self.showinfo. text =@" Add success "; }else{self.showinfo. text =@" add failed ";}}];Copy the code
  1. Query a piece of data
BmobQuery *bquery = [BmobQuery queryWithClassName:@"Customer"]; / / id 0 c6db13c inside the GameScore table lookup data [bquery getObjectInBackgroundWithId: self. The userId block: ^ (NSError BmobObject * object If (object) {playerName and cheatMode NSString *playerName = [object objectForKey:@"UserName"]; BOOL cheatMode = [[object objectForKey:@"cheatMode"] boolValue];  NSLog(@"%@----%i",playerName,cheatMode); self.showInfo.text =playerName; } } }];Copy the code
  1. Delete a piece of data
BmobQuery *bquery = [BmobQuery queryWithClassName:@"Customer"]; [bquery getObjectInBackgroundWithId:self.userId block:^(BmobObject *object, NSError *error){if (error) {else{if (object) {// Delete object [object deleteInBackground]; Self.showinfo. Text =@" delete successfully ";}}}];Copy the code

Bmob console

For other operations, see the official documents. The code is uploaded to GittHub, and you are welcome to follow the public account JackerooChu for more articles.