BuiltClass Class Reference

Inherits from NSObject
Declared in BuiltClass.h

Overview

A Class is a collection of objects.

Other Methods

  extensionKey

To set extensionKey for the class. // ‘blt5d4sample2633b’ is a dummy Application API key

@property (nonnull, nonatomic, strong) NSString *extensionKey

Discussion

//Obj-C BuiltApplication builtApplication = [Built applicationWithAPIKey:@“blt5d4sample2633b”]; BuiltClass projectClass = [builtApplication classWithUID:@“project”]; projectClass.extensionKey = @“new_extension”;

//Swift var builtApplication:BuiltApplication = Built.applicationWithAPIKey(“blt5d4sample2633b”) var projectClass:BuiltClass = builtApplication.classWithUID(“project”) projectClass.extensionKey = “new_extension”;

Declared In

BuiltClass.h

Headers

– setHeader:forKey:

Set a header for an application

- (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey

Parameters

headerValue

The header key

headerKey

The header value

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 [projectClass setHeader:@"MyValue" forKey:@"My_Custom_Header"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 projectClass.setHeader("MyValue", forKey:"My_Custom_Header")

Declared In

BuiltClass.h

– addHeadersWithDictionary:

Set a header for an application

- (void)addHeadersWithDictionary:(NSDictionary *)headers

Parameters

headers

The headers as dictionary which needs to be added to the application

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 [projectClass addHeadersWithDictionary:@{@"Custom_Key":@"Custom_Value"}];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 projectClass.addHeadersWithDictionary(["Custom_Key": "Custom_Value"])

Declared In

BuiltClass.h

– removeHeaderForKey:

Removes a header from this application.

- (void)removeHeaderForKey:(NSString *)headerKey

Parameters

headerKey

The header key that needs to be removed

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 [projectClass removeHeaderForKey:@"Custom_Key"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 projectClass.removeHeaderForKey("Custom_Key")

Declared In

BuiltClass.h

BuiltObject Instance

– object

Represents an Object of a class

- (BuiltObject *)object

Return Value

Returns new BuiltObject instance

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltObject *projectObject = [projectClass object];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var projectObject:BuiltObject = projectClass.object()

Declared In

BuiltClass.h

– objectWithUID:

Represents an Object of a class

- (BuiltObject *)objectWithUID:(NSString *)uid

Parameters

uid

Object UID

Return Value

Returns new BuiltObject instance

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltObject *projectObject = [projectClass objectWithUID:@"blt73815f9c277d2d98"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var projectObject:BuiltObject = projectClass.objectWithUID("blt73815f9c277d2d98")

Declared In

BuiltClass.h

BuiltQuery Instance

– query

Represents a Query on ‘Class’ which can be executed to retrieve objects that pass the query condition

- (BuiltQuery *)query

Return Value

Returns new BuiltQuery instance

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltQuery *builtQuery = [projectClass query];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var builtQuery:BuiltQuery = projectClass.query()

Declared In

BuiltClass.h

Schema

– fetchSchema:

Gets the schema of class asynchronously

- (void)fetchSchema:(void ( ^ ) ( BuiltResponseType responseType , NSArray *BUILT_NULLABLE_P schema , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

completionBlock

Completion block with params (BuiltResponseType responseType, NSArray schema, NSError error)

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 [projectClass fetchSchema:^(BuiltResponseType responseType, NSArray *schema, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 projectClass.fetchSchema { (responseType, schema, error) -> Void in

 }

Declared In

BuiltClass.h

Cancel Network calls

– cancelRequests

Advises the operation object that it should stop executing its task.

- (void)cancelRequests

Discussion

This method does not force your operation code to stop. Instead, it updates the object’s internal flags to reflect the change in state. If the operation has already finished executing, this method has no effect. Canceling an operation that is currently in an operation queue, but not yet executing, makes it possible to remove the operation from the queue sooner than usual.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 [projectClass cancelRequests];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 projectClass.cancelRequests()

Declared In

BuiltClass.h

Realtime Methods

– on:callback:

Registers a event listener on Class.

- (void)on:(BuiltRealtimeEventType)eventType callback:(EventCallback)callback

Parameters

eventType

event types i.e Create/Upate/Delete/Broadcast explained above

callback

response object if success or error object

Discussion

For list of supported events, check BuiltRealtimeEventType

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 //just for example we are using BuiltRealtimeEventTypeUpdate.
 [projectClass on:BuiltRealtimeEventTypeUpdate callback:^(id response, NSError *error) {
    if (error) {
        //some error occured while listening
    }else {
        //Class schema type NSDictionary instance in response which is recently updated
    }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 //just for example we are using BuiltRealtimeEventType.Update.
 projectClass.on(BuiltRealtimeEventType.Update, callback: { (response, error) -> Void in
    if (error != nil) {
        //some error occured while listening
    }else {
        //Class schema type NSDictionary instance in response which is recently updated
    }
 })

Warning: Not supported in watchOS

Declared In

BuiltClass+Realtime.h

– off:callback:

Unregisters a single or all event listener(s) from Class.

- (void)off:(BuiltRealtimeEventType)eventType callback:(EventCallback)callback

Parameters

eventType

Create/Update/Delete/Broadcast

callback

response object if success or error object

Discussion

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 //just for example we are using BuiltRealtimeEventTypeUpdate.
 [projectClass off:BuiltRealtimeEventTypeUpdate callback:^(id response, NSError *error) {
     if (error) {
        //some error occured while unregister
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 //just for example we are using BuiltRealtimeEventType.Update.
 projectClass.off(BuiltRealtimeEventType.Update, callback: { (response, error) -> Void in
     if (error != nil) {
        //some error occured while unregister
     }
 })

Warning: Not supported in watchOS

Declared In

BuiltClass+Realtime.h

– broadcastWithMessage:callback:

Sending a broadcast message to all the classes of particular class if class object is created by classUID.

- (void)broadcastWithMessage:(NSString *)message callback:(EventCallback)callback

Parameters

message

message to broadcast

callback

callback called once broadcast message is send if error occurs error object will be received.

Discussion

 // 'blt5d4sample2633b' is dummy Application API key

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 [projectClass broadcastWithMessage:@"Hello world" callback:^(id response, NSError *error) {
     if (error) {
        // error while sending message
     }else {
        // sent broadcast message successfully
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 projectClass.broadcastWithMessage("Hello World", callback: { (response, error) -> Void in
     if (error != nil) {
        // error while sending message
     }else {
        // sent broadcast message successfully
     }
 })

Warning: Not supported in watchOS

Declared In

BuiltClass+Realtime.h