ApptimizeCodeBlock

@interface ApptimizeCodeBlock : NSObject

Wraps a code block with its corresponding name.

Useful in Swift for passing closures to +runTest:withBaseline:apptimizeCodeBlocks:andOptions:

  • Name to give this code block. Should match variant name associated with this code block.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nonnull) NSString *name;

    Swift

    var name: String { get set }
  • Code block to execute when enrolled in a variant matching name.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nonnull) void (^)(void) block;

    Swift

    var block: () -> Void { get set }
  • Initialize an ApptimizeCodeBlock that contains block and corresponding name

    Declaration

    Objective-C

    - (nonnull instancetype)initWithName:(nonnull NSString *)name
                                andBlock:(nonnull void (^)(void))block;

    Swift

    init(name: String, andBlock block: @escaping () -> Void)

    Parameters

    name

    The name of the code block, should match the variant name this code block is associated with.

    block

    The code block to execute when enrolled in the variant matching name.

    Return Value

    Returns a new ApptimizeCodeBlock containing a named closure.