iOS client library written in Objective-C for SeatGeak's Sixpack ab testing framework.
The recommended way to use Sixpack-iOS is through CocoaPods
Sixpack-iOS.podspec is available through CocoaPods, to install it simply add the following line to your Podfile:
pod "Sixpack-iOS"
If you wish to include Sixpack-iOS manually in your project, you must add the SixPackClient Xcode project to your project's workspace.
You will also have to add the appropriate AFNetworking 2.0 source files to the Sixpack-iOS project in order for linking to complete successfully.
1. Connect to the Sixpack host
Call connectToHost
before any other Sixpack calls.
Usually inside: application:didFinishLaunchingWithOptions:
The Url should be the location of your sixpack mountpoint:
[Sixpack connectToHost:@"http://my.sixpack.host:8129/sixpack/mount/point"];
2. Set up the experiments
Call setupExperiment once for each experiment after calling connectToHost
and before participating:
[Sixpack setupExperiment:@"myExperiment"
alternatives:@[@"optionA", @"optionB"];
3. Participate in an experiment
Call participate
to participate in an experiment. The chosen alternative is returned in the onChoose
block:
[Sixpack participateIn:@"myExperiment"
onChoose:^(NSString *chosenAlternative) {
if ([chosenAlternative isEqualToString:@"optionA"]) {
... Do option A work
} else if ([chosenAlternative isEqualToString:@"optionB"]) {
... Do option B work
}
}];
4. Convert
Call convert
with the experiment name once the goal is achieved:
[Sixpack convert:@"myExperiment"];
After participating in an experiment, you can retrieve the chosen alternative for that experiment at any time:
+ (NSString *)chosenAlternativeFor:(NSString *)experiment;
After participating in an experiment, you can check for whether a particular alternative was chosen:
+ (BOOL)chosenAlternativeFor:(NSString *)experiment is:(NSString *)alternative;
For Example:
if ([Sixpack chosenAlternativeFor:@"myExperiment" is:@"optionA"]) {
[self.view addSubview:self.viewA];
} else {
[self.view addSubview:self.viewB];
}
Use this setup method to force an experiment result:
+ (void)setupExperiment:(NSString *)experiment
alternatives:(NSArray *)alternatives
forceChoice:(NSString *)forcedChoice;
You can turn on and off debug logging. Logging defaults to On for DEBUG builds and Off for RELEASE builds. You should ensure this is off before submitting to the app store
+ (void)enableDebugLogging:(BOOL)debugLogging;
Sixpack-iOS is available under the FreeBSD license. See the LICENSE file for more info.