Inherits from NSObject
Conforms to FileHolder
Declared in KiiObject.h

Overview

A server-compatible object for generic storage use cases

Tasks

Other Methods

Object Body Handling

Resumable Transfer Handling

Properties

bodyContentType

The content type of object body. nil by default, the value will be set automatically after successful upload/download object body operation. The value will be nullified after object deletion or object body deletion.

@property (nonatomic, readonly, nullable) NSString *bodyContentType

Discussion

The content type of object body. nil by default, the value will be set automatically after successful upload/download object body operation. The value will be nullified after object deletion or object body deletion.

Declared In

KiiObject.h

bucket

The bucket that owns this object

@property (readonly) KiiBucket *bucket

Discussion

The bucket that owns this object

Declared In

KiiObject.h

created

The date the object was created on the server

@property (strong, readonly, nullable) NSDate *created

Discussion

The date the object was created on the server

Declared In

KiiObject.h

modified

The date the object was last modified on the server

@property (strong, readonly, nullable) NSDate *modified

Discussion

The date the object was last modified on the server

Declared In

KiiObject.h

objectACL

Get the ACL handle for this file. Any KiiACLEntry objects added or revoked from this ACL object will be appended to/removed from the server on ACL save.

@property (readonly) KiiACL *objectACL

Discussion

Get the ACL handle for this file. Any KiiACLEntry objects added or revoked from this ACL object will be appended to/removed from the server on ACL save.

Declared In

KiiObject.h

objectType

The application-defined class name of the object

@property (strong, readonly, nullable) NSString *objectType

Discussion

The application-defined class name of the object

Declared In

KiiObject.h

objectURI

Get a specifically formatted string referencing the object. The object must exist in the cloud (have a valid UUID).

@property (strong, readonly, nullable) NSString *objectURI

Discussion

Get a specifically formatted string referencing the object. The object must exist in the cloud (have a valid UUID).

Declared In

KiiObject.h

uuid

The unique id of the object, assigned by the server

@property (readonly, nullable) NSString *uuid

Discussion

The unique id of the object, assigned by the server

Declared In

KiiObject.h

Class Methods

objectWithURI:

Create a KiiObject that references an existing object

+ (nullable KiiObject *)objectWithURI:(NSString *)uri

Parameters

uri

An object-specific URI

Return Value

a working KiiObject. nil is returned when the uri is invalid.

Discussion

Create a KiiObject that references an existing object

Declared In

KiiObject.h

Instance Methods

delete:withCallback:

Asynchronously deletes an object from the server.

- (void)delete:(id)delegate withCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) objectDeleted:(KiiObject*)object withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the object
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously deletes an object from the server.

Delete an object from the server. This method is non-blocking.

Declared In

KiiObject.h

deleteBodySynchronous:

Synchronously deletes an object’s body from the server.

- (BOOL)deleteBodySynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously deletes an object’s body from the server.

Delete an object’s body from the server. This method is blocking.

Declared In

KiiObject.h

deleteBodyWithBlock:

Asynchronously deletes an object’s body from the server.

- (void)deleteBodyWithBlock:(KiiObjectBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously deletes an object’s body from the server.

Delete an object’s body from the server. This method is non-blocking.

 [obj deleteBodyWithBlock:^(KiiObject *object, NSError *error) {
     if(error == nil) {
        NSLog(@"Object's body deleted!");
     }
 }];

Declared In

KiiObject.h

deleteSynchronous:

Synchronously deletes an object from the server.

- (BOOL)deleteSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously deletes an object from the server.

Delete an object from the server. This method is blocking.

Declared In

KiiObject.h

deleteWithBlock:

Asynchronously deletes an object from the server.

- (void)deleteWithBlock:(KiiObjectBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously deletes an object from the server.

Delete an object from the server. This method is non-blocking.

 [obj deleteWithBlock:^(KiiObject *object, NSError *error) {
     if(error == nil) {
         NSLog(@"Object deleted!");
     }
 }];

Declared In

KiiObject.h

describe

Prints the contents of this object to log

- (void)describe

Discussion

Prints the contents of this object to log

For developer purposes only, this method prints the object in a readable format to the log for testing.

Declared In

KiiObject.h

dictionaryValue

Gets a dictionary value of all attributes of this object including read only value obtained from server response

- (NSDictionary *)dictionaryValue

Discussion

Gets a dictionary value of all attributes of this object including read only value obtained from server response

Declared In

KiiObject.h

downloadBodySynchronousWithURL:andError:

Synchronously download object body.

- (BOOL)downloadBodySynchronousWithURL:(NSURL *)destinationFileURL andError:(NSError *_Nullable *_Nullable)error

Parameters

destinationFileURL

url for destination file, it should have ‘file://’ scheme.

error

An NSError object, set to nil to test for errors.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously download object body.

This is blocking method. If destination file exist, it will be overwriten.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

If the file url path is not writable, an error (Error code : 519) will be returned.

Declared In

KiiObject.h

downloadBodyWithURL:andCompletion:

Asynchronously download object body with completion.

- (void)downloadBodyWithURL:(NSURL *)destinationFileURL andCompletion:(nullable KiiObjectBodyCompletionBlock)completion

Parameters

destinationFileURL

url for destination file, it should have ‘file://’ scheme.

completion

block for handling completion.

Discussion

Asynchronously download object body with completion.

This is non blocking method. If destination file exist, it will be overwriten.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

If the file url path is not writable, an error (Error code : 519) will be returned.

    [object downloadBodyWithURL:destinationFileURL
                   andCompletion:^(KiiObject *obj, NSError *error)
    {
        // do something on completion
    }];

Declared In

KiiObject.h

downloadBodyWithURL:andCompletion:andProgess:

@deprecated

- (void)downloadBodyWithURL:(NSURL *)destinationFileURL andCompletion:(nullable KiiObjectBodyCompletionBlock)completion andProgess:(nullable KiiObjectBodyProgressBlock)progess

Discussion

@deprecated

Declared In

KiiObject.h

downloadBodyWithURL:andCompletion:andProgress:

Asynchronously download object body with progress and completion. This is non blocking method. If destination file exist, it will be overwriten.

- (void)downloadBodyWithURL:(NSURL *)destinationFileURL andCompletion:(nullable KiiObjectBodyCompletionBlock)completion andProgress:(nullable KiiObjectBodyProgressBlock)progress

Parameters

destinationFileURL

url for destination file, it should have ‘file://’ scheme.

completion

block for handling completion.

progress

block for handling progress.

Discussion

Asynchronously download object body with progress and completion. This is non blocking method. If destination file exist, it will be overwriten.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

If the file url path is not writable, an error (Error code : 519) will be returned.

    [object downloadBodyWithURL:destinationFileURL
                   andCompletion:^(KiiObject *obj, NSError *error)
    {
        // do something during download progress
    }
    andProgress:^(KiiObject *obj, NSUInteger completedSizeInBytes, NSUInteger totalSizeInBytes, NSError *error)
    {
        // do something on completion
    }];

Declared In

KiiObject.h

downloader:

Get downloader. If there is no downloader in the app, it will be created new instance

- (KiiDownloader *)downloader:(NSString *)localPath

Parameters

localPath

Path that will be used by the downloader. If file exists, will be overwritten.

Return Value

A KiiDownloader instance associated to this object

Discussion

Get downloader. If there is no downloader in the app, it will be created new instance

Declared In

KiiObject.h

generateDownloadRequest

Generate NSURLRequest instance for downloading object body.

- (nullable NSURLRequest *)generateDownloadRequest

Return Value

NSURLRequest instance to download object body.

Discussion

Generate NSURLRequest instance for downloading object body.

The generated request can be used to implement iOS 7 background transfer feature.

If the object does not have id, nil will be returned.

If the object body does not exist, it fails on execution.

Note that refresh token won’t be executed even if the login users access token is going to expired.

Declared In

KiiObject.h

generateUploadRequest

Generate NSURLRequest instance for uploading object body.

- (nullable NSURLRequest *)generateUploadRequest

Return Value

NSURLRequest instance to upload object body.

Discussion

Generate NSURLRequest instance for uploading object body.

The generated request can be used to implement iOS 7 background transfer feature.

If the object does not have id, nil will be returned.

If the object does not exist, it fails on execution.

Note that refresh token won’t be executed even if the login users access token is going to expired.

Note: If you upload object body with this method, object body content-type value is set always “application/octet-stream”. If you want to set object body content type, please use [KiiObject generateUploadRequest:] instead.

Declared In

KiiObject.h

generateUploadRequest:

Generate NSURLRequest instance for uploading object body with specified content type.

- (nullable NSURLRequest *)generateUploadRequest:(nullable NSString *)contentType

Parameters

contentType

Content type of the object body. Please refer to http://www.iana.org/assignments/media-types/media-types.xhtml for the standard. If nil is passed, it will be set as “application/octet-stream”.

Return Value

NSURLRequest instance to upload object body.

Discussion

Generate NSURLRequest instance for uploading object body with specified content type.

The generated request can be used to implement iOS 7 background transfer feature.

If the object does not have id, nil will be returned. If the object does not exist, it fails on execution.

Note that refresh token won’t be executed even if the login users access token is going to expired.

Declared In

KiiObject.h

getGeoPointForKey:

Gets the GeoPoint associated with the given key

- (nullable KiiGeoPoint *)getGeoPointForKey:(NSString *)key

Parameters

key

The key to retrieve

Return Value

An object if the key exists, null otherwise

Discussion

Gets the GeoPoint associated with the given key

Declared In

KiiObject.h

getObjectForKey:

Gets the value associated with the given key

- (nullable id)getObjectForKey:(NSString *)key

Parameters

key

The key to retrieve

Return Value

An object if the key exists, null otherwise

Discussion

Gets the value associated with the given key

Declared In

KiiObject.h

hasObject:

Checks to see if an object exists for a given key

- (BOOL)hasObject:(NSString *)key

Parameters

key

The key to check for existence

Return Value

True if the object exists, false otherwise.

Discussion

Checks to see if an object exists for a given key

Declared In

KiiObject.h

publishBodyExpiresAt:withBlock:

Asynchronously Publish the KiiObject attached file and return the file URL. URL will be expired at the specified expiration date.

- (void)publishBodyExpiresAt:(NSDate *)expirationDate withBlock:(KiiObjectPublishBodyBlock)block

Parameters

expirationDate

defined expiration date.

block

completion block. See code snippet above.

Discussion

Asynchronously Publish the KiiObject attached file and return the file URL. URL will be expired at the specified expiration date.

This is non blocking method. URL of published object body refers to the original object body, any updates on original will reflect.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

If the expirationDate is not future date, an error (Error code : 521) will be returned.

    [object publishBodyExpiresAt:expirationDate andBlock:^(KiiObject *obj, NSString *url, NSError *error) {
        if (error){
        // error handling;
        }else{
        NSLog(@"Published URL : %@",url);
        //do something with the URL
        }
    }];

Exceptions

NSInvalidArgumentException

will be thrown if completion block is nil.

Declared In

KiiObject.h

publishBodyExpiresIn:withBlock:

Asynchronously Publish the KiiObject body and return the public URL. URL will be expired in time interval since now.

- (void)publishBodyExpiresIn:(NSUInteger)timeInterval withBlock:(KiiObjectPublishBodyBlock)block

Parameters

timeInterval

NSUInteger time interval since now (in seconds).

block

completion block.

Discussion

Asynchronously Publish the KiiObject body and return the public URL. URL will be expired in time interval since now.

This is non blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

If the file url path is not writable, an error (Error code : 519) will be returned.

If the timeInterval is 0, an error (Error code : 522) will be returned.

    NSUinteger nextOneHour = 60 * 60;
    [object publishBodyExpiresIn:nextOneHour andBlock:^(KiiObject *obj,NSString *url, NSError *error) {
        if (error){
        // error handling;
        }else{
        NSLog(@"Published URL : %@",url);
        //do something with the URL
        }
    }];

Exceptions

NSInvalidArgumentException

will be thrown if completion block is nil.

Declared In

KiiObject.h

publishBodySynchronous:

Synchronously Publish the KiiObject body and return the public URL. URL will not be expired.

- (nullable NSString *)publishBodySynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

An NSError object, set to nil to test for errors.

Return Value

the URL for the KiiObject body contents.

Discussion

Synchronously Publish the KiiObject body and return the public URL. URL will not be expired.

This is blocking method. URL of published object body refers to the original object body, any updates on original will reflect.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

Declared In

KiiObject.h

publishBodySynchronousExpiresAt:andError:

Synchronously Publish the KiiObject body and return the public URL. URL will be expired at the specified expiration date.

- (nullable NSString *)publishBodySynchronousExpiresAt:(NSDate *)expirationDate andError:(NSError *_Nullable *_Nullable)error

Parameters

expirationDate

defined expiration date.

error

An NSError object, set to nil to test for errors.

Return Value

the URL for the KiiObject body contents.

Discussion

Synchronously Publish the KiiObject body and return the public URL. URL will be expired at the specified expiration date.

This is blocking method. URL of published object body refers to the original object body, any updates on original will reflect.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

If the expirationDate is not future date, an error (Error code : 521) will be returned.

Declared In

KiiObject.h

publishBodySynchronousExpiresIn:andError:

Synchronously Publish the KiiObject body and return the public URL. URL will be expired in the specified time interval since now.

- (nullable NSString *)publishBodySynchronousExpiresIn:(NSUInteger)timeInterval andError:(NSError *_Nullable *_Nullable)error

Parameters

timeInterval

NSUInteger time interval since now (in seconds).

error

An NSError object, set to nil to test for errors.

Return Value

the URL for the KiiObject body contents.

Discussion

Synchronously Publish the KiiObject body and return the public URL. URL will be expired in the specified time interval since now.

This is blocking method. URL of published object body refers to the original object body, any updates on original will reflect.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

If the timeInterval is 0, an error (Error code : 522) will be returned.

Declared In

KiiObject.h

publishBodyWithBlock:

Asynchronously Publish the KiiObject body and return the public URL. URL will not be expired.

- (void)publishBodyWithBlock:(KiiObjectPublishBodyBlock)block

Parameters

block

completion block.

Discussion

Asynchronously Publish the KiiObject body and return the public URL. URL will not be expired.

This is non blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the object does not have body, an error (Error code : 517) will be returned.

    [object publishBodyWithBlock:^(KiiObject *object, NSString *url, NSError *error) {
         if (error){
         // error handling;
         }else{
         NSLog(@"Published URL : %@",url);
         //do something with the URL
        }
    }];

Exceptions

NSInvalidArgumentException

will be thrown if completion block is nil.

Declared In

KiiObject.h

refresh:withCallback:

Asynchronously updates the local object’s data with the object data on the server

- (void)refresh:(id)delegate withCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) objectRefreshed:(KiiObject*)object withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the object
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously updates the local object’s data with the object data on the server

The object must exist on the server. Local data will be overwritten.

Declared In

KiiObject.h

refreshSynchronous:

Synchronously updates the local object’s data with the object data on the server

- (BOOL)refreshSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously updates the local object’s data with the object data on the server

The object must exist on the server. Local data will be overwritten. This is a blocking method.

Declared In

KiiObject.h

refreshWithBlock:

Asynchronously updates the local object’s data with the object data on the server

- (void)refreshWithBlock:(KiiObjectBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously updates the local object’s data with the object data on the server

The object must exist on the server. Local data will be overwritten.

 [obj refreshWithBlock:^(KiiObject *object, NSError *error) {
     if(error == nil) {
         NSLog(@"Object refreshed: %@", object);
     }
 }];

Declared In

KiiObject.h

removeObjectForKey:

Removes a specific key/value pair from the object If the key exists, the key/value will be removed from the object.

- (void)removeObjectForKey:(NSString *)key

Parameters

key

The key of the key/value pair that will be removed.

Discussion

Removes a specific key/value pair from the object If the key exists, the key/value will be removed from the object.

Note: Since version 2.1.30, the behavior of this API has been changed. This method just removes the key-value pair from the local cache but no longer sets empty string (@“”) to the key and does not send specified key-value pair to the cloud when the update method ([KiiObject saveSynchronous:] etc.) is called. If you want to have same effect as previous, please execute setObject:forKey: with empty string (@“”) passed to the object explicitly.

Declared In

KiiObject.h

save:withBlock:

Asynchronously saves the latest object values to the server

- (void)save:(BOOL)forced withBlock:(KiiObjectBlock)block

Parameters

forced

Set to TRUE if the local copy should overwrite the remote copy, even if the remote copy is newer. Set to FALSE otherwise.

block

The block to be called upon method completion. See example

Discussion

Asynchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists and forced is set to TRUE, all fields on the server will be replaced by the fields defined locally. Otherwise, only changed fields will be modified. This is a non-blocking method.

 [obj save:TRUE withBlock:^(KiiObject *object, NSError *error) {
     if(error == nil) {
         NSLog(@"Object saved: %@", object);
     }
 }];

Note: This API can not create new KiiObject on cloud when instantiated by [KiiBucket createObjectWithID:], but can only update. If you want to create new KiiObject with it, please use saveAllFieldsSynchronous:withError:, saveAllFields:withBlock: or saveAllFields:withDelegate:andCallback: instead.

Declared In

KiiObject.h

save:withCallback:

Asynchronously saves the latest object values to the server

- (void)save:(id)delegate withCallback:(SEL)callback

Parameters

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) objectSaved:(KiiObject*)object withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the object
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists, the fields that have changed locally will be updated accordingly. This is a non-blocking method.

Note: This API can not create new KiiObject on cloud when instantiated by [KiiBucket createObjectWithID:], but can only update. If you want to create new KiiObject with it, please use saveAllFieldsSynchronous:withError:, saveAllFields:withBlock: or saveAllFields:withDelegate:andCallback: instead.

Declared In

KiiObject.h

save:withDelegate:andCallback:

Asynchronously saves the latest object values to the server

- (void)save:(BOOL)forced withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

forced

Set to TRUE if the local copy should overwrite the remote copy, even if the remote copy is newer. Set to FALSE otherwise.

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

- (void) objectSaved:(KiiObject*)object withError:(NSError*)error {

    // the request was successful
    if(error == nil) {
        // do something with the object
    }

    else {
        // there was a problem
    }
}

Discussion

Asynchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists and forced is set to TRUE, all fields on the server will be replaced by the fields defined locally. Otherwise, only changed fields will be modified. This is a non-blocking method.

Note: This API can not create new KiiObject on cloud when instantiated by [KiiBucket createObjectWithID:], but can only update. If you want to create new KiiObject with it, please use saveAllFieldsSynchronous:withError:, saveAllFields:withBlock: or saveAllFields:withDelegate:andCallback: instead.

Declared In

KiiObject.h

saveAllFields:withBlock:

Asynchronously saves the latest object values to the server

- (void)saveAllFields:(BOOL)forced withBlock:(KiiObjectBlock)block

Parameters

forced

Set to TRUE if the local copy should overwrite the remote copy, even if the remote copy is newer. Set to FALSE otherwise.

block

The block to be called upon method completion. See example

Discussion

Asynchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists, all fields will be removed or changed to match the local values. This is a non-blocking method.

 [obj save:TRUE withBlock:^(KiiObject *object, NSError *error) {
     if(error == nil) {
         NSLog(@"Object saved: %@", object);
     }
 }];

Declared In

KiiObject.h

saveAllFields:withDelegate:andCallback:

Asynchronously saves the latest object values to the server

- (void)saveAllFields:(BOOL)forced withDelegate:(id)delegate andCallback:(SEL)callback

Parameters

forced

Set to TRUE if the local copy should overwrite the remote copy, even if the remote copy is newer. Set to FALSE otherwise.

delegate

The object to make any callback requests to

callback

The callback method to be called when the request is completed. The callback method should have a signature similar to:

 - (void) objectSaved:(KiiObject*)object withError:(NSError*)error {

     // the request was successful
     if(error == nil) {
         // do something with the object
     }

     else {
         // there was a problem
     }
 }

Discussion

Asynchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists, all fields will be removed or changed to match the local values. This is a non-blocking method.

Declared In

KiiObject.h

saveAllFieldsSynchronous:withError:

Synchronously saves the latest object values to the server

- (BOOL)saveAllFieldsSynchronous:(BOOL)forced withError:(NSError *_Nullable *_Nullable)error

Parameters

forced

Set to TRUE if the local copy should overwrite the remote copy, even if the remote copy is newer. Set to FALSE otherwise.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists, all fields will be removed or changed to match the local values. This is a blocking method.

Declared In

KiiObject.h

saveSynchronous:

Synchronously saves the latest object values to the server

- (BOOL)saveSynchronous:(NSError *_Nullable *_Nullable)error

Parameters

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists, the fields that have changed locally will be updated accordingly. This is a blocking method.

Note: This API can not create new KiiObject on cloud when instantiated by [KiiBucket createObjectWithID:], but can only update. If you want to create new KiiObject with it, please use saveAllFieldsSynchronous:withError:, saveAllFields:withBlock: or saveAllFields:withDelegate:andCallback: instead.

Declared In

KiiObject.h

saveSynchronous:withError:NS_SWIFT_NAME:

Synchronously saves the latest object values to the server

- (BOOL)saveSynchronous:(BOOL)forced withError:(NSError *_Nullable *_Nullable)error NS_SWIFT_NAME

Parameters

forced

Set to TRUE if the local copy should overwrite the remote copy, even if the remote copy is newer. Set to FALSE otherwise.

error

used to return an error by reference (pass NULL if this is not desired). It is recommended to set an actual error object to get the error information.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists and forced is set to TRUE, all fields on the server will be replaced by the fields defined locally. Otherwise, only changed fields will be modified. This is a blocking method.

Note: This API can not create new KiiObject on cloud when instantiated by [KiiBucket createObjectWithID:], but can only update. If you want to create new KiiObject with it, please use saveAllFieldsSynchronous:withError:, saveAllFields:withBlock: or saveAllFields:withDelegate:andCallback: instead.

Declared In

KiiObject.h

saveWithBlock:

Asynchronously saves the latest object values to the server

- (void)saveWithBlock:(KiiObjectBlock)block

Parameters

block

The block to be called upon method completion. See example

Discussion

Asynchronously saves the latest object values to the server

If the object does not yet exist, it will be created. If the object already exists, the fields that have changed locally will be updated accordingly. This is a non-blocking method.

 [obj saveWithBlock:^(KiiObject *object, NSError *error) {
     if(error == nil) {
         NSLog(@"Object saved: %@", object);
     }
 }];

Note: This API can not create new KiiObject on cloud when instantiated by [KiiBucket createObjectWithID:], but can only update. If you want to create new KiiObject with it, please use saveAllFieldsSynchronous:withError:, saveAllFields:withBlock: or saveAllFields:withDelegate:andCallback: instead.

Declared In

KiiObject.h

setGeoPoint:forKey:

Set GeoPoint to this object with the specified key.

- (BOOL)setGeoPoint:(KiiGeoPoint *)point forKey:(NSString *)key

Parameters

point

GeoPoint to be set to the specified key.

key

The key to set. The key must not be a system key (created, metadata, modified, type, uuid) or begin with an underscore (_)

Discussion

Set GeoPoint to this object with the specified key.

Declared In

KiiObject.h

setObject:forKey:

Sets a key/value pair to a KiiObject

- (BOOL)setObject:(nullable id)object forKey:(NSString *)key

Parameters

object

The value to be set. Object must be of a JSON-encodable type (Ex: NSDictionary, NSArray, NSString, NSNumber, etc)

key

The key to set. The key must not be a system key (created, metadata, modified, type, uuid) or begin with an underscore (_)

Return Value

True if the object was set, false otherwise.

Discussion

Sets a key/value pair to a KiiObject

If the key already exists, its value will be written over. If the object is of invalid type, it will return false and an NSError will be thrown (quietly). Accepted types are any JSON-encodable objects. NOTE: Before involving floating point value, please consider using integer instead. For example, use percentage, permil, ppm, etc. The reason is: - Will dramatically improve the performance of bucket query. - Bucket query does not support the mixed result of integer and floating point. ex.) If you use same key for integer and floating point and inquire object with the integer value, objects which has floating point value with the key would not be evaluated in the query. (and vice versa)

Declared In

KiiObject.h

uploadBodySynchronousWithData:andContentType:andError:

Synchronously upload object body.

- (BOOL)uploadBodySynchronousWithData:(NSData *)data andContentType:(nullable NSString *)contentType andError:(NSError *_Nullable *_Nullable)error

Parameters

data

NSData to upload. This is mandatory, can not be nil. An invalid parameter exception will be thrown if nil is passed.

contentType

Content type of the object body. Please refer to http://www.iana.org/assignments/media-types/media-types.xhtml for the standard. If nil is passed, it will be set as “application/octet-stream”.

error

An NSError object, set to nil to test for errors.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously upload object body.

This is blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

Note: After this operation, KiiObject version on cloud will be updated. If you want to use <saveSynchronous:withError:> or saveAllFieldsSynchronous:withError: with overwrite=NO argument, please do refreshSynchronous: before saving.

Exceptions

NSInvalidArgumentException

if data is nil.

Declared In

KiiObject.h

uploadBodySynchronousWithURL:andContentType:andError:

Synchronously upload object body.

- (BOOL)uploadBodySynchronousWithURL:(NSURL *)sourceFileURL andContentType:(nullable NSString *)contentType andError:(NSError *_Nullable *_Nullable)error

Parameters

sourceFileURL

url for source file, it should have ‘file://’ scheme.

contentType

Content type of the object body. Please refer to http://www.iana.org/assignments/media-types/media-types.xhtml for the standard. If nil is passed, it will be parsed from URL’s file extension.

error

An NSError object, set to nil to test for errors.

Return Value

YES if succeeded, NO otherwise.

Discussion

Synchronously upload object body.

This is blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the file url path is not exist or is a directory, an error (Error code : 518) will be returned.

If the file url path is not readable, an error (Error code : 520) will be returned.

Note: After this operation, KiiObject version on cloud will be updated. If you want to use <saveSynchronous:withError:> or saveAllFieldsSynchronous:withError: with overwrite=NO argument, please do refreshSynchronous: before saving.

Declared In

KiiObject.h

uploadBodyWithData:andContentType:andCompletion:

Asynchronously upload object body with completion.

- (void)uploadBodyWithData:(NSData *)data andContentType:(nullable NSString *)contentType andCompletion:(nullable KiiObjectBodyCompletionBlock)completion

Parameters

data

NSData to upload. This is mandatory, can not be nil. An invalid parameter exception will be thrown if nil is passed.

contentType

Content type of the object body. Please refer to http://www.iana.org/assignments/media-types/media-types.xhtml for the standard. If nil is passed, it will be set as “application/octet-stream”.

completion

block for handling completion.

Discussion

Asynchronously upload object body with completion.

This is non blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

    [object uploadBodyWithData:data
                 andCompletion:^(KiiObject *obj, NSError *error)
                {
                // do something during download progress
    }];

Note: After this operation, KiiObject version on cloud will be updated. If you want to use <saveSynchronous:withError:> or saveAllFieldsSynchronous:withError: with overwrite=NO argument, please do refreshSynchronous: before saving.

Exceptions

NSInvalidArgumentException

if data is nil.

Declared In

KiiObject.h

uploadBodyWithData:andContentType:andCompletion:andProgess:

@deprecated

- (void)uploadBodyWithData:(NSData *)data andContentType:(nullable NSString *)contentType andCompletion:(nullable KiiObjectBodyCompletionBlock)completion andProgess:(nullable KiiObjectBodyProgressBlock)progess

Discussion

@deprecated

Declared In

KiiObject.h

uploadBodyWithData:andContentType:andCompletion:andProgress:

Asynchronously upload object body with progress and completion.

- (void)uploadBodyWithData:(NSData *)data andContentType:(nullable NSString *)contentType andCompletion:(nullable KiiObjectBodyCompletionBlock)completion andProgress:(nullable KiiObjectBodyProgressBlock)progress

Parameters

data

NSData to upload. This is mandatory, can not be nil. An invalid parameter exception will be thrown if nil is passed.

contentType

Content type of the object body. Please refer to http://www.iana.org/assignments/media-types/media-types.xhtml for the standard. If nil is passed, it will be set as “application/octet-stream”.

completion

block for handling completion.

progress

block for handling progress.

Discussion

Asynchronously upload object body with progress and completion.

This is non blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

     [object uploadBodyWithData:data
         andCompletion:^(KiiObject *obj, NSError *error)
         {
         // do something during download progress
         }
         andProgress:^(KiiObject *obj, NSUInteger completedSizeInBytes, NSUInteger totalSizeInBytes, NSError *error)
         {
         // do something on completion
     }];

Note: After this operation, KiiObject version on cloud will be updated. If you want to use <saveSynchronous:withError:> or saveAllFieldsSynchronous:withError: with overwrite=NO argument, please do refreshSynchronous: before saving.

Exceptions

NSInvalidArgumentException

if data is nil.

Declared In

KiiObject.h

uploadBodyWithURL:andContentType:andCompletion:

Asynchronously upload object body with completion.

- (void)uploadBodyWithURL:(NSURL *)sourceFileURL andContentType:(nullable NSString *)contentType andCompletion:(nullable KiiObjectBodyCompletionBlock)completion

Parameters

sourceFileURL

url for source file, it should have ‘file://’ scheme.

contentType

Content type of the object body. Please refer to http://www.iana.org/assignments/media-types/media-types.xhtml for the standard. If nil is passed, it will be parsed from URL’s file extension.

completion

block for handling completion.

Discussion

Asynchronously upload object body with completion.

This is non blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the file url path is not exist or is a directory, an error (Error code : 518) will be returned.

If the file url path is not readable, an error (Error code : 520) will be returned.

    [object uploadBodyWithURL:sourceFileURL
        andCompletion:^(KiiObject *obj, NSError *error)
        {
        // do something on completion
    }];

Note: After this operation, KiiObject version on cloud will be updated. If you want to use <saveSynchronous:withError:> or saveAllFieldsSynchronous:withError: with overwrite=NO argument, please do refreshSynchronous: before saving.

Declared In

KiiObject.h

uploadBodyWithURL:andContentType:andCompletion:andProgess:

@deprecated

- (void)uploadBodyWithURL:(NSURL *)sourceFileURL andContentType:(nullable NSString *)contentType andCompletion:(nullable KiiObjectBodyCompletionBlock)completion andProgess:(nullable KiiObjectBodyProgressBlock)progess

Discussion

@deprecated

Declared In

KiiObject.h

uploadBodyWithURL:andContentType:andCompletion:andProgress:

Asynchronously upload object body with progress and completion.

- (void)uploadBodyWithURL:(NSURL *)sourceFileURL andContentType:(nullable NSString *)contentType andCompletion:(nullable KiiObjectBodyCompletionBlock)completion andProgress:(nullable KiiObjectBodyProgressBlock)progress

Parameters

sourceFileURL

url for source file, it should have ‘file://’ scheme.

contentType

Content type of the object body. Please refer to http://www.iana.org/assignments/media-types/media-types.xhtml for the standard. If nil is passed, it will be set as “application/octet-stream”.

completion

block for handling completion.

progress

block for handling progress.

Discussion

Asynchronously upload object body with progress and completion.

This is non blocking method.

If the object does not have id, an error (Error code : 501) will be returned.

If the object is not found on the server, an error (Error code : 510) will be returned.

If the file url path is not exist or is a directory, an error (Error code : 518) will be returned.

If the file url path is not readable, an error (Error code : 520) will be returned.

    [object uploadBodyWithURL:sourceFileURL
andCompletion:^(KiiObject *obj, NSError *error)
        {
        // do something during download progress
        }
andProgress:^(KiiObject *obj, NSUInteger completedSizeInBytes, NSUInteger totalSizeInBytes, NSError *error)
        {
        // do something on completion
    }];

Note: After this operation, KiiObject version on cloud will be updated. If you want to use <saveSynchronous:withError:> or saveAllFieldsSynchronous:withError: with overwrite=NO argument, please do refreshSynchronous: before saving.

Declared In

KiiObject.h

uploader:

Get uploader. If there is no uploader in the app, it will be created new instance

- (KiiUploader *)uploader:(NSString *)localPath

Parameters

localPath

Path that will be used by the uploader.

Return Value

A KiiUploader instance associated to this object

Discussion

Get uploader. If there is no uploader in the app, it will be created new instance

Declared In

KiiObject.h