Inherits from NSObject
Declared in KiiExperiment.h

Overview

KiiExperiment is a class that handle experiment for AB testing feature.

Properties

chosenVariation

Returns chosen variation if the experiment has finished with specified variation.

@property (nonatomic, readonly, nullable) KiiVariation *chosenVariation

Return Value

Variation chosen or nil if when the no variation has not been chosen.

Discussion

Returns chosen variation if the experiment has finished with specified variation.

Declared In

KiiExperiment.h

conversionEvents

Get all conversion events in this experiment.

@property (nonatomic, readonly, nullable) NSArray *conversionEvents

Discussion

Get all conversion events in this experiment.

Declared In

KiiExperiment.h

experimentDescription

Get the description of the experiment.

@property (nonatomic, readonly, nullable) NSString *experimentDescription

Discussion

Get the description of the experiment.

Declared In

KiiExperiment.h

experimentID

Get the id of the experiment.

@property (nonatomic, readonly) NSString *experimentID

Discussion

Get the id of the experiment.

Declared In

KiiExperiment.h

status

Get the status of the experiment.

@property (nonatomic, readonly) KiiExperimentStatus status

Discussion

Get the status of the experiment.

Declared In

KiiExperiment.h

variations

Get the variations associated with this experiment.

@property (nonatomic, readonly, nullable) NSArray *variations

Return Value

an array of KiiVariation, nil if there is no variation found.

Discussion

Get the variations associated with this experiment.

Declared In

KiiExperiment.h

version

Get the version number of the experiment.

@property (nonatomic, readonly) int version

Discussion

Get the version number of the experiment.

Declared In

KiiExperiment.h

Class Methods

getExperiment:withBlock:

Get experiment asynchronously having the specified id with block. This is non-blocking methods.

+ (void)getExperiment:(NSString *)experimentID withBlock:(KiiExperimentBlock)completion

Parameters

experimentID

experiment id.

completion

The block to be called upon method completion. See example.

Discussion

Get experiment asynchronously having the specified id with block. This is non-blocking methods.

 [KiiExperiment getExperiment:experimentID withBlock:^(KiiExperiment *experiment, NSError *error) {
     if(error == nil) {
         NSLog(@"Experiment: %@", experiment);
     }
 }];

Exceptions

NSInvalidArgumentException

Thrown if given experiment id is
- Nil or empty
- Does not match with the pattern [a-zA-Z0-9-_.]{2,100}“

Declared In

KiiExperiment.h

getExperimentSynchronous:withError:

Get experiment synchronously having the specified id. This is blocking methods.

+ (nullable KiiExperiment *)getExperimentSynchronous:(NSString *)experimentID withError:(NSError *_Nullable *_Nullable)error

Parameters

experimentID

experiment id.

error

An NSError object, passed by reference.

Return Value

an instant of KiiExperiment.

Discussion

Get experiment synchronously having the specified id. This is blocking methods.

Exceptions

NSInvalidArgumentException

Thrown if given experiment id is
- Nil or empty
- Does not match with the pattern [a-zA-Z0-9-_.]{2,100}“

Declared In

KiiExperiment.h

Instance Methods

appliedVariationWithError:

Get the variation applied to this trial. Get the variation applied to this trial. Variation will be determined by specified rate of each variation in this experiment.

- (nullable KiiVariation *)appliedVariationWithError:(NSError *_Nullable *_Nullable)error

Parameters

error

An NSError object, passed by reference.

Discussion

Get the variation applied to this trial. Get the variation applied to this trial. Variation will be determined by specified rate of each variation in this experiment.

Current login user information will be used for sampling. If the experiment has finished with specified variant, the specified variant will be returned regardless of login user information.

  • If the experiment is in draft an error (code 902) will be returned.
  • If the experiment has been paused an error (code 903) will be returned.
  • If the experiment has been terminated without specified variant an error (code 904) will be returned.
  • If No user logged in, an error (code 906) will be returned.

Declared In

KiiExperiment.h

appliedVariationWithSampler:andError:

Get the variation applied to this trial.
Sampler should return the variation according to the rate defined in this experiment. If you use KiiVariationSamplerByKiiUser with current login user, it will be same as appliedVariationWithError: .

- (nullable KiiVariation *)appliedVariationWithSampler:(nullable id<KiiVariationSampler>)sampler andError:(NSError *_Nullable *_Nullable)error

Parameters

sampler

an instance of object that conform KiiVariationSampler protocol.

error

An NSError object, passed by reference.

Discussion

Get the variation applied to this trial.
Sampler should return the variation according to the rate defined in this experiment. If you use KiiVariationSamplerByKiiUser with current login user, it will be same as appliedVariationWithError: .

Note: An error will be returned if the experiment is not applied, depending on implementation of KiiVariationSampler.

Declared In

KiiExperiment.h

appliedVariationWithSampler:fallback:

Get the variation applied to this trial.
Sampler should return the variation according to the rate defined in this experiment. If sampler fails to return applied variation, then fallback is returned. If you use KiiVariationSamplerByKiiUser with current login user, it will be same as appliedVariationWithError:.

- (nullable KiiVariation *)appliedVariationWithSampler:(nullable id<KiiVariationSampler>)sampler fallback:(nullable KiiVariation *)fallback

Parameters

sampler

an instance of object that conform KiiVariationSampler protocol.

fallback

fallback The variation to return when failed to get the applied variation.

Return Value

applied variation for this trial or fallback.

Discussion

Get the variation applied to this trial.
Sampler should return the variation according to the rate defined in this experiment. If sampler fails to return applied variation, then fallback is returned. If you use KiiVariationSamplerByKiiUser with current login user, it will be same as appliedVariationWithError:.

Declared In

KiiExperiment.h

conversionEventAtIndex:

Get conversion event by index.

- (nullable KiiConversionEvent *)conversionEventAtIndex:(int)index

Parameters

index

an index of conversion. Should be on variations array bounds.

Return Value

an instance of KiiVariation, nil if there is no element found for specified index.

Discussion

Get conversion event by index.

Declared In

KiiExperiment.h

conversionEventByName:

Get conversion event by its name.

- (nullable KiiConversionEvent *)conversionEventByName:(NSString *)name

Parameters

name

of the Conversion Event.

Return Value

an instance of KiiVariation, nil if there is no conversion found for specified name.

Discussion

Get conversion event by its name.

Declared In

KiiExperiment.h

variationByName:

Get the variation which has the specified name.

- (nullable KiiVariation *)variationByName:(NSString *)name

Parameters

name

variation name.

Return Value

an instance of KiiVariation. nil if there is no variation which have specified name.

Discussion

Get the variation which has the specified name.

Declared In

KiiExperiment.h