PFCloud

Objective-C

@interface PFCloud : NSObject

Swift

class PFCloud : NSObject

The PFCloud class provides methods for interacting with Parse Cloud Functions.

  • Calls the given cloud function asynchronously with the parameters provided.

    Declaration

    Objective-C

    + (nonnull BFTask<id> *)callFunctionInBackground:(nonnull NSString *)function
                                      withParameters:
                                          (nullable NSDictionary *)parameters;

    Swift

    class func callFunction(inBackground function: String, withParameters parameters: [AnyHashable : Any]?) -> BFTask<AnyObject>

    Parameters

    function

    The function name to call.

    parameters

    The parameters to send to the function.

    Return Value

    The task, that encapsulates the work being done.

  • Calls the given cloud function asynchronously with the parameters provided and executes the given block when it is done.

    Declaration

    Objective-C

    + (void)callFunctionInBackground:(nonnull NSString *)function
                      withParameters:(nullable NSDictionary *)parameters
                               block:(nullable PFIdResultBlock)block;

    Swift

    class func callFunction(inBackground function: String, withParameters parameters: [AnyHashable : Any]?, block: PFIdResultBlock? = nil)

    Parameters

    function

    The function name to call.

    parameters

    The parameters to send to the function.

    block

    The block to execute when the function call finished. It should have the following argument signature: ^(id result, NSError *error).

Deprecated

  • Deprecated

    Please use PFCloud.+callFunctionInBackground:withParameters: instead.

    Calls the given cloud function asynchronously with the parameters provided and then executes the given selector when it is done.

    @deprecated Please use PFCloud.+callFunctionInBackground:withParameters: instead.

    Declaration

    Objective-C

    + (void)callFunctionInBackground:(nonnull NSString *)function
                      withParameters:(nullable NSDictionary *)parameters
                              target:(nullable id)target
                            selector:(nullable SEL)selector;

    Swift

    class func callFunction(inBackground function: String, withParameters parameters: [AnyHashable : Any]?, target: Any?, selector: Selector?)

    Parameters

    function

    The function name to call.

    parameters

    The parameters to send to the function.

    target

    The object to call the selector on.

    selector

    The selector to call when the function call finished. It should have the following signature: (void)callbackWithResult:(id)result error:(NSError *)error. Result will be nil if error is set and vice versa.

Synchronous

  • Calls the given cloud function synchronously with the parameters provided.

    Declaration

    Objective-C

    + (nullable id)callFunction:(nonnull NSString *)function
                 withParameters:(nullable NSDictionary *)parameters;

    Parameters

    function

    The function name to call.

    parameters

    The parameters to send to the function.

    Return Value

    The response from the cloud function.

  • Calls the given cloud function synchronously with the parameters provided and sets the error if there is one.

    Declaration

    Objective-C

    + (nullable id)callFunction:(nonnull NSString *)function
                 withParameters:(nullable NSDictionary *)parameters
                          error:(NSError *_Nullable *_Nullable)error;

    Swift

    class func callFunction(_ function: String, withParameters parameters: [AnyHashable : Any]?) throws -> Any

    Parameters

    function

    The function name to call.

    parameters

    The parameters to send to the function.

    error

    Pointer to an NSError that will be set if necessary.

    Return Value

    The response from the cloud function. This result could be a NSDictionary, an NSArray, NSNumber or NSString.