Documentation : iOS Simple Tutorial

This is a simple example where we describe how to sync blog entries between devices. To develop this case you should:

  • design simple model with two fields
  • deploy our simple app on test enviroment
  • configure your app on the mobile
  • use our API to sync your model between devices

Create your App

Start working with the Mobeelizer. Create your FREE account.

Let's design your first App. Open the Mobeelizer App Designer and login with your account. Then, press CREATE NEW APPLICATION button and insert it's name blog.

Design your App Schema

In your applications designer panel enter Models section on the left. Then create new model Blog and add two text fields to it.

Deploy your App into the test environment

Deploy your app into the test environment using DEPLOY TO TEST button.

Get the Mobeelizer SDK

Prepare plain iOS poject, get the Mobeelizer SDK, unzip it and add it as a framework to the project 

Get your App definition

Download App definition and save it into the project directory as "application.xml".

 

Confligure your App

Create "Mobeelizer.plist" file and configure your App.

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version = "1.0">
<dict>
     <key>mode</key>
     <string>test</string>
     <key>developmentRole</key>
     <string>users-mobile</string>
     <key>modelPrefix</key>
     <string>YourModelPrefix</string>
     <key>device</key>
     <string>mobile</string>
</dict>
</plist>

Want to know what these properties mean? Check the documentation for detailed description.

Create Blog object

Create class "Blog" with "YourModelPrefix" prefix.

// YourModelPrefixBlog.h
#import <Foundation/Foundation.h>
@interface YourModelPrefixBlog : NSObject
	@property ( nonatomic , strong) NSString *guid;
	@property ( nonatomic , strong) NSString *title;
	@property ( nonatomic , strong) NSString *content;
@end

// YourModelPrefixBlog.m
#import "YourModelPrefixBlog.h"
	@implementation MMItem
	@synthesize guid, title, content;
@end

Looking for information how to convert schema definition into objects? Check the documentation for detailed description.

Use the Mobeelizer SDK

Open Application Delegate and add the messages for creating and destroying Mobeelizer.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
	// your code here
	[Mobeelizer create];
	return YES;
}
- (void)applicationWillTerminate:(UIApplication *)application {
	// your code here
	[Mobeelizer destroy];
}

Before any object will be stored the device must be authenticated.

MobeelizerOperationError *error = [Mobeelizer loginUser:@"user" andPassword:@"password"];
 
if(error != nil) {
  // login error, more info in error.message
}

Once you are logged in you have access to the database.

MobeelizerDatabase *database = [Mobeelizer database];

Let's create a Blog object and store it in the database.

YourModelPrefixBlog *blog = [[YourModelPrefixBlog alloc] init];
blog.title = @"First entry";
blog.content = @"I'm proud to announce that my first application is working properly.";
MobeelizerErrors *errors = [database save:blog];

So we have stored our very first object. Let's check it.

BOOL exists = [database exists:[YourModelPrefixBlog  class] withGuid:blog.guid]; // => TRUE
long count = [database count:[YourModelPrefixBlog  class ]]; // => 1
YourModelPrefixBlog *blogFromDatabase = [database get:[YourModelPrefixBlog class] withGuid:blog.guid]; // => blogFromDatabase != Nil

Is our Blog entry shared in the cloud? It will be soon.

MobeelizerOperationError *error = [Mobeelizer sync];

if(error != nil) {
  // login error, more info in error.message
}

Remember to logout before closing the application.

[Mobeelizer logout];

Run the App on the device

That's all. Compile your App and deploy it to the device. Then create a blog entry and sync it with the cloud. It will be visible by other devices.

 

Attachments:

insert_application_name.png (image/png)
download_iOS_SDK.png (image/png)
a52e2bab22d6ce7f9ea10d854b8ea561.png (image/png)
newModel.png (image/png)
newField1.png (image/png)
newField2.png (image/png)
deploy.png (image/png)