PFConfig

Objective-C

@interface PFConfig : NSObject

Swift

class PFConfig : NSObject

PFConfig is a representation of the remote configuration object. It enables you to add things like feature gating, a/b testing or simple “Message of the day”.

Current Config

  • Returns the most recently fetched config.

    If there was no config fetched - this method will return an empty instance of PFConfig.

    Declaration

    Objective-C

    + (nonnull PFConfig *)currentConfig;

    Swift

    class func current() -> PFConfig

    Return Value

    Current, last fetched instance of PFConfig.

  • Returns the task that encapsulates the most recently fetched config.

    If there was no config fetched - this method will return an empty instance of PFConfig.

    Declaration

    Objective-C

    + (id)getCurrentConfigInBackground;

    Swift

    class func getCurrentConfigInBackground() -> Any!

    Return Value

    Task that encapsulates current, last fetched instance of PFConfig.

Retrieving Config

  • Gets the PFConfig asynchronously and sets it as a result of a task.

    Declaration

    Objective-C

    + (id)getConfigInBackground;

    Swift

    class func getInBackground() -> Any!

    Return Value

    The task, that encapsulates the work being done.

  • Gets the PFConfig asynchronously and executes the given callback block.

    Declaration

    Objective-C

    + (void)getConfigInBackgroundWithBlock:(nullable PFConfigResultBlock)block;

    Swift

    class func inBackground() async throws -> PFConfig

    Parameters

    block

    The block to execute. It should have the following argument signature: ^(PFConfig *config, NSError *error).

Parameters

  • Returns the object associated with a given key.

    Declaration

    Objective-C

    - (nullable id)objectForKey:(nonnull NSString *)key;

    Swift

    func object(forKey key: String) -> Any?

    Parameters

    key

    The key for which to return the corresponding configuration value.

    Return Value

    The value associated with key, or nil if there is no such value.

  • Returns the object associated with a given key.

    This method enables usage of literal syntax on PFConfig. E.g. NSString *value = config[@"key"];

    See

    objectForKey:

    Declaration

    Objective-C

    - (nullable id)objectForKeyedSubscript:(nonnull NSString *)keyedSubscript;

    Swift

    subscript(keyedSubscript: String) -> Any? { get }

    Parameters

    keyedSubscript

    The keyed subscript for which to return the corresponding configuration value.

    Return Value

    The value associated with key, or nil if there is no such value.

Retrieving Config

  • Gets the PFConfig object synchronously from the server.

    Declaration

    Objective-C

    + (nullable PFConfig *)getConfig;

    Return Value

    Instance of PFConfig if the operation succeeded, otherwise nil.

  • Gets the PFConfig object synchronously from the server and sets an error if it occurs.

    Declaration

    Objective-C

    + (nullable PFConfig *)getConfig:(NSError *_Nullable *_Nullable)error;

    Swift

    class func getConfig() throws -> PFConfig

    Parameters

    error

    Pointer to an NSError that will be set if necessary.

    Return Value

    Instance of PFConfig if the operation succeeded, otherwise nil.