SVSAdRules

Objective-C

@interface SVSAdRules : NSObject <NSCopying, NSCoding>

Swift

class SVSAdRules : NSObject, NSCopying, NSCoding

Represents a set of ad rules.

Initializers

  • Initialize a SVSAdRules instance from an array of valid ad rules.

    Declaration

    Objective-C

    - (nullable instancetype)initWithRules:(nonnull NSArray<SVSAdRule *> *)adRules;

    Swift

    init?(rules adRules: [SVSAdRule])

    Parameters

    adRules

    An array of valid SVSAdRule instances.

    Return Value

    An initialized SVSAdRules instance or nil if the adRules array is empty.

  • Initialize a SVSAdRules instance from a valid ad rules JSON.

    Declaration

    Objective-C

    - (nullable instancetype)initWithJSON:(nonnull NSString *)jsonRules;

    Swift

    convenience init?(json jsonRules: String)

    Parameters

    jsonRules

    A string containing a valid ad rules JSON.

    Return Value

    An initialized SVSAdRules instance or nil if the JSON is not valid.

Convenience initializers

  • Creates a SVSAdRules instance from an array of valid ad rules.

    Declaration

    Objective-C

    + (nonnull instancetype)adRulesWithRules:
        (nonnull NSArray<SVSAdRule *> *)adRules;

    Parameters

    adRules

    An array of valid SVSAdRule instances.

    Return Value

    An initialized SVSAdRules instance.

  • Creates a SVSAdRules instance from a valid ad rules JSON.

    Declaration

    Objective-C

    + (nonnull instancetype)adRulesWithJSON:(nonnull NSString *)jsonRules;

    Parameters

    jsonRules

    A string containing a valid ad rules JSON.

    Return Value

    An initialized SVSAdRules instance or nil if the JSON is not valid.

  • Asynchronously retrieve a JSON based ad rules set from a given URL.

    Warning

    The execution thread for the completion handler is not guaranteed. If you make UI modification in this handler, make sure to perform them on the main thread.

    Declaration

    Objective-C

    + (void)adRulesFromURL:(nonnull NSURL *)adRulesURL
         completionHandler:(nonnull void (^)(SVSAdRules *_Nullable,
                                             NSError *_Nullable))completionHandler;

    Swift

    class func adRules(from adRulesURL: URL) async throws -> SVSAdRules

    Parameters

    adRulesURL

    The URL of the JSON describing the ad rules.

    completionHandler

    The completion handler that will be called with the SVSAdRules object (or with an error if the ad rules object can be retrieved).