LiObject Reference


Inherits From: NSObject
Declared In: LiObject.h

Overview


Applicasa ships with a default set of pre-defined datastore objects, which are exposed to developers as native objects. Developers can also use the Applicasa datastore to define custom objects.

LiObject is the base class from which all Applicasa-generated object classes are derived. As developers modify the default datastore, adding extra fields to existing objects, or creating new object types for their custom application needs, Applicasa generates additional native classes to allow native interactions. All generated classes subclass the LiObject class, and their standard methods are included here.


Tasks


Creating Objects

- initWithDictionary:
- initWithDictionary:andHeader:
- initWithObject:

Retrieving Objects

+ getById:queryKind:withBlock:
+ getArrayWithQuery:queryKind:withBlock:
+ getLocalArrayWithRawSQLQuery:andBlock:

Modifying Objects

- saveWithBlock:
- uploadFile:toField:withFileType:extension:andBlock:
- deleteWithBlock:


Properties


itemId

The item's unique ID value.

@property (nonatomic, retain) NSString *itemId;

Discussion:

This is an object's unique ID value as recorded in the Applicasa datastore. It is set by the datastore whenever the saveWithBlock: method is called. You can use this for such tasks as, among other custom uses, querying objects by their ID value to retrieve a specific object from the datastore.

lastUpdated

A NSDate value of the last time the object was updated.

@property (nonatomic, retain, readonly) NSDate *lastUpdated;

Discussion:

The lastUpdated value is calculated by the Applicasa SDK and datastore. It is advised that developers not alter this value directly.


Class Methods


getById:queryKind:withBlock:

Class method for retrieving an object by ID value.

+ (void) getById:(NSString *)Id queryKind:(QueryKind)queryKind withBlock:(Get[Class]Finished)block;

Parameters:

Id
An NSString value representing the ID value of the object you wish to retrieve.

queryKind
A QueryKind constant indicating which type of query you wish to perform. Options are FULL, LIGHT, and LOCAL.

block
A block that allows a developer to respond to method completion. Must match the signature (NSError *error, [Class] *object), where [Class] is a placeholder for the calling class (e.g., User, VirtualGood, etc.).

Discussion:

This method allows a developer to retrieve an object from the Applicasa datastore, indicate what kind of query the developer wishes to perform, and requires a block that matches the signature (NSError error, [Class] object), where [Class] is a placeholder for the calling class (e.g., User, VirtualGood, etc.).

Because Applicasa generates custom native classes for your application on the fly, based on the Objects defined for your application via the web console, the block argument will always follow the same signature, but the type of class object returned will always match the calling class. Thus, if you are calling getById:queryKind:withBlock: from the User class, the block signature will be (NSError *error, User *object). This ensures that inside your block, you are guaranteed to be working with a properly typed object of the calling class.

Applicasa also provides a great deal of power to your queries via the queryKind parameter. This allows you to specify whether you want to perform a network query that looks up all related objects for their most recent values (FULL); a network query that only retrieves deltas of the most recent data for the given object itself, without looking up related objects (LIGHT); or a local-only query that hits the offline sqlite datastore Applicasa creates to ensure your application keeps working even when a network connection does not exist (LOCAL).

getArrayWithQuery:queryKind:withBlock:

Class method for retrieving an object with a custom query.

+ (void) getArrayWithQuery:(LiQuery *)query queryKind:(QueryKind)queryKind withBlock:(Get[Class]ArrayFinished)block;

Parameters:

query
An LiQuery instance representing the query for the objects you wish to retrieve.

queryKind
A QueryKind constant indicating which type of query you wish to perform. Options are FULL, LIGHT, and LOCAL.

block
A block that allows a developer to respond to method completion. Must match the signature (NSError *error, NSArray *array).

Discussion:

This method allows a developer to retrieve an object from the Applicasa datastore, indicate what kind of query the developer wishes to perform, and requires a block that matches the signature (NSError *error, NSArray *array). The array instance passed to the block will contain all the objects that matched your query.

Applicasa also provides a great deal of power to your queries via the queryKind parameter. This allows you to specify whether you want to perform a network query that looks up all related objects for their most recent values (FULL); a network query that only retrieves deltas of the most recent data for the given object itself, without looking up related objects (LIGHT); or a local-only query that hits the offline sqlite datastore Applicasa creates to ensure your application keeps working even when a network connection does not exist (LOCAL).

getLocalArrayWithRawSQLQuery:andBlock:

Class method for retrieving an object locally (only) with a raw SQL statement.

+ (void) getLocalArrayWithRawSQLQuery:(NSString *)rawQuery andBlock:(Get[Class]ArrayFinished)block;

Parameters:

rawQuery
An SQL query representing the objects you wish to retrieve.

block
A block that allows a developer to respond to method completion. Must match the signature (NSError *error, NSArray *array).

Discussion:

This method allows a developer to retrieve an object from the local Applicasa datastore via a raw SQL query, and requires a block that matches the signature (NSError *error, NSArray *array). The array instance passed to the block will contain all the objects that matched your query.


Instance Methods


initWithDictionary:

Instance method to initialize a new Object from an NSDictionary instance.

- (id) initWithDictionary:(NSDictionary *)item;

Parameters:

item
An NSDictionary of data keyed by object field names.

Return Value:

An object instance of the calling class.

Discussion:

initWithDictionary: allows a developer to build up a dictionary of object key:value pairs that correspond to an object's field names and the desired values you wish to save.

initWithDictionary:andHeader:

Instance method to initialize a new Object from an NSDictionary instance and a custom NSString header value.

- (id) initWithDictionary:(NSDictionary *)item andHeader:(NSString*)header;

Parameters:

item
An NSDictionary of data keyed by object field names.

header
An NSString consisting of custom header value

Return Value:

An object instance of the calling class.

Discussion:

initWithDictionary:andHeader: allows a developer to initialize a new Object from an NSDictionary instance and a custom NSString header value.

initWithObject:

Instance method to initialize a new Object from an LiObject instance.

- (id) initWithObject:(LiObject *)object;

Parameters:

object
An LiObject instance used to instantiate a new LiObject instance.

Return Value:

An object instance of the calling class.

Discussion:

initWithObject: is typically used by the Applicasa SDK and Framework to return objects of derived SDK classes a developer is actually interacting with.

saveWithBlock:

Instance method for saving Applicasa SDK objects.

- (void) saveWithBlock:(LiBlockAction)block;

Parameters:

block
A block that must match the signature (NSError *error, NSString *itemID, Actions action).

Discussion:

Instance method for saving Applicasa SDK objects that allows a developer to respond to method completion. This block must match the signature (NSError *error, NSString *itemID, Actions action).

increaseField:byValue:

Instance method for increasing numeric fields by a supplied value.

- (void) increaseField:(LiField)field byValue:(NSNumber *)value;

Parameters:

field
The field you wish to update, a constant from LiField.

value
An NSNumber indicating the value by which you wish to increase field.

Discussion:

Instance method for increasing numeric fields by a supplied value.

uploadFile:toField:withFileType:extension:andBlock:

Instance method for uploading a file to a given object field.

- (void) uploadFile:(NSData *)data toField:(LiField)field withFileType:(AMAZON_FILE_TYPES)fileType extension:(NSString *)ext andBlock:(LiBlockAction)block;

Parameters:

data
An NSData object representing the image data you wish to upload.

field
The LiField constant indicating to which field name you wish to upload.

fileType
A valid fileType argument indicating what type of file you are uploading. Valid values are Image, Text, and Pdf.

ext
An NSString indicating the extension of the file you are uploading.

block
A block that must match the signature (NSError *error, NSString *itemID, Actions action).

Discussion:

This method enables a developer to upload a file to an object field via the Applicasa SDK. It uploads the file to Amazon S3, and provides a block that allows you to respond to method completion. The block must match the signature (NSError *error, NSString *itemID, Actions action).

deleteWithBlock:

Deletes Applicasa objects.

- (void) deleteWithBlock:(LiBlockAction)block;

Parameters:

block
A block that must match the signature (NSError *error, NSString *itemID, Actions action).

Discussion:

Deletes Applicasa objects and allows a developer to respond to method completion via the block parameter. This block must match the signature (NSError *error, NSString *itemID, Actions action).


  « Back to SDK Class List