SVSAdRules
Objective-C
@interface SVSAdRules : NSObject <NSCopying, NSCoding>
Swift
class SVSAdRules : NSObject, NSCopying, NSCoding
Represents a set of ad rules.
-
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
adRulesAn 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
jsonRulesA string containing a valid ad rules JSON.
Return Value
An initialized SVSAdRules instance or nil if the JSON is not valid.
-
Creates a SVSAdRules instance from an array of valid ad rules.
Declaration
Objective-C
+ (nonnull instancetype)adRulesWithRules: (nonnull NSArray<SVSAdRule *> *)adRules;Parameters
adRulesAn 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
jsonRulesA 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 -> SVSAdRulesParameters
adRulesURLThe URL of the JSON describing the ad rules.
completionHandlerThe completion handler that will be called with the SVSAdRules object (or with an error if the ad rules object can be retrieved).