Optimizely Class Reference

Inherits from NSObject
Declared in Optimizely.h

Overview

This class defines the Optimizely SDK interface.

The Optimizely SDK is organized around a singleton, accessible via the sharedInstance method. Through this singleton, you can configure Optimizely.

Methods associated with retrieving variables, code blocks and tracking goals are available as class methods.

Initialization

+ sharedInstance

This method provides access to the Optimizely singleton.

+ (instancetype)sharedInstance

Return Value

The Optimizely singleton

Declared In

Optimizely.h

+ startOptimizelyWithAPIToken:launchOptions:

Calling this activates the Optimizely framework. If not called, the app will behave as though Optimizely wasn’t included.

+ (void)startOptimizelyWithAPIToken:(NSString *)apiToken launchOptions:(NSDictionary *)launchOptions

Parameters

apiToken

The apiToken of your iOS project on Optimizely.

launchOptions

A dictionary of launch options. This is typically the launch options passed into -application: didFinishLaunchingWithOptions:.

Discussion

This method attempts to fetch the latest Optimizely experiment data with a timeout of two seconds and returns immediately after the data has been successfully loaded. In the case of a timeout and when no experiment data is available, the user will not be counted as a visitor to your experiment.

Declared In

Optimizely.h

+ startOptimizelyWithAPIToken:launchOptions:experimentsLoadedCallback:

Calling this activates the Optimizely framework. If not called, the app will behave as though Optimizely wasn’t included.

+ (void)startOptimizelyWithAPIToken:(NSString *)apiToken launchOptions:(NSDictionary *)launchOptions experimentsLoadedCallback:(OptimizelySuccessBlock)experimentsLoadedCallback

Parameters

apiToken

The apiToken of your iOS project on Optimizely.

launchOptions

A dictionary of launch options. This is typically the launch options passed into -application: didFinishLaunchingWithOptions:.

experimentsLoadedCallback

A block that will be executed when the Optimizely framework has activated any experiments that pass targeting.

Discussion

This method will return immediately. However, accessing live variables, code blocks or Optimizely views involved in an active experiment prior to receiving a successful callback will prevent the experiment from running on this launch.

The experimentsLoadedCallback is guaranteed to be called exactly once. If no data file has been cached (e.g. if this is the first launch) then the experimentsLoadedCallback will not be called until the latest experiments file has been downloaded from the server. If the device is in edit mode, the callback will execute immediately.

Declared In

Optimizely.h

+ setValue:forCustomTag:

This method allows you to add custom tags for targeting.

+ (void)setValue:(NSString *)tagValue forCustomTag:(NSString *)tagKey

Parameters

tagValue

Value for custom tag

tagKey

Key for custom tag

Discussion

Warning: Ideally this method should be called before +startOptimizelyWithAPIToken because we will then use these tags to determine which experiments to activate for the user. But if you want to add additional tags after Optimizely has started you can use refreshExperiments to force Optimizely to try activating experiments while taking into account your new tags.

Declared In

Optimizely.h

+ handleOpenURL:

This method is intended to notify Optimizely that the app has been opened via URL and the user wishes to enter edit mode. Typically, this should be placed in application:handleOpenURL:

+ (BOOL)handleOpenURL:(NSURL *)url

Parameters

url

The url passed to application:handleOpenURL:

Return Value

Returns true if the provided URL is an Optimizely URL, false otherwise.

Declared In

Optimizely.h

+ enableEditor

This method makes the device available to the Optimizely web editor.

+ (void)enableEditor

Discussion

It is a programmatic shortcut for developers to place the device in edit mode, rather than opening the app through the custom URL accessible in the Optimizely web editor.

Warning: We recommend that this call be wrapped in an #ifdef DEBUG flag. It should be removed from test and production builds.

Warning: Should be called before startOptimizelyWithAPIToken.

Declared In

Optimizely.h

+ enablePreview

This method enables the preview mode on the device/simulator.

+ (void)enablePreview

Discussion

It provides an alternate way of opening the app, bypassing the use of the custom URL or web editor.

Warning: We recommend that this call be wrapped in an #ifdef DEBUG flag. It should be removed from test and production builds.

Warning: Should be called before startOptimizelyWithAPIToken.

Declared In

Optimizely.h

+ disableSwizzle

This method deactivates the swizzling functionality of the SDK required for use of the visual editor.

+ (void)disableSwizzle

Discussion

Warning: Should be called before startOptimizelyWithAPIToken.

Declared In

Optimizely.h

+ enableGestureInAppStoreApp

This method enables the Optimizely gesture that launches your app into edit mode for builds of your app downloaded from the app store.

+ (void)enableGestureInAppStoreApp

Discussion

Warning: Must be called before startOptimizelyWithAPIToken.

Declared In

Optimizely.h

Events and Goal Tracking

+ dispatch

This method immediately starts a network request that sends tracked events to Optimizely and fetches the newest experiment data file.

+ (void)dispatch

Discussion

This is the same as calling dispatchEvents followed by fetchNewDataFile.

Events are automatically flushed at regular intervals by the SDK. This method exists so that the Optimizely SDK can piggy-back on an already activated radio. This can save battery by reducing the number of times the radio is turned on/off.

See dispatchInterval to change the frequency of auto dispatch (events and new data file).

Declared In

Optimizely.h

+ dispatchEvents

Manually send events to Optimizely.

+ (void)dispatchEvents

Declared In

Optimizely.h

+ fetchNewDataFile

Manually fetch new data file from Optimizely.

+ (void)fetchNewDataFile

Declared In

Optimizely.h

+ trackEvent:

This method informs Optimizely that a custom goal with key description occured.

+ (void)trackEvent:(NSString *)description

Parameters

description

A unique string identifying the custom goal

See Also

Declared In

Optimizely.h

+ trackRevenue:withDescription:

This method informs Optimizely that a revenue goal custom event occured.

+ (void)trackRevenue:(int)revenueAmount withDescription:(NSString *)description

Parameters

revenueAmount

The revenue amount in cents associated with the event

description

The description of the revenue. This will only be shown in the raw event log.

See Also

Declared In

Optimizely.h

Utilities and Helpers

+ refreshExperiments

This method manually refreshes all currently running experiments so as to take into account the most recent targeting conditions and tags.

+ (void)refreshExperiments

Discussion

Note: The use of this method may invalidate statistical results.

Declared In

Optimizely.h

+ getExperimentDataById:

This method gets the experiment data for a given experimentId

+ (OptimizelyExperimentData *)getExperimentDataById:(NSString *)experimentId

Parameters

experimentId

The id of the particular experiment. The ID is available in the bottom of the experiment details panel from the project view.

Return Value

OptimizelyExperimentData returns the experiment data if the experiment is found. returns nil otherwise

Declared In

Optimizely.h

+ isUserInAudience:

This method determines whether a user is in a particular audience.

+ (BOOL)isUserInAudience:(NSString *)audienceId

Parameters

audienceId

The audienceId that we’re trying to check against

Return Value

BOOL true if user satisfies the audience conditions, false otherwise

Declared In

Optimizely.h

+ resetUserBucketing

This method resets the bucketing metadata that is cached on device. This will also clear the random user id, so that next time the experiment is activated, the user will be bucketed as a fresh user. This will also clear the Optimizely DataFile from storage.

+ (void)resetUserBucketing

Declared In

Optimizely.h

+ getAudiences

This method returns a copy of all audiences that are defined in the data file. If this is called before Optimizely starts, it will return an empty array. If there are no audiences, it will return an empty array. Each audience will be an index in the NSArray represented by a NSDictionary. Each NSDictionary will have 3 keys: @“name”, @“audience_id”, and @“conditions” @“name” keys to a NSString of the audience name in the web editor. @“audience_id” keys to a NSString of the unique audience identifier. @“conditions” keys to a JSON representation of the audience conditions.

+ (NSArray *)getAudiences

Return Value

NSArray of all audiences.

Declared In

Optimizely.h

+ activateManualExperiment:

Activates a manual experiment with the given id. If it passes targeting, the experiment will be bucketed and marked as visited. This must be called after startOptimizelyWithAPIToken.

+ (BOOL)activateManualExperiment:(NSString *)experimentId

Parameters

experimentId

The id of the experiment you wish to activate

Return Value

boolean depending on whether or not we successfully activated the experiment. Turn on verbose logging for more debugging info

Declared In

Optimizely.h

+ activateAllManualExperiments

Activates all manual experiments in your data file. If it passes targeting, the experiments will be bucketed and marked as visited. This must be called after startOptimizelyWithAPIToken.

+ (BOOL)activateAllManualExperiments

Return Value

boolean depending on whether or not we were able to activate all manual experiments. Turn on verbose logging for more debugging info.

Declared In

Optimizely.h

+ forceVariation:ofExperiment:

Buckets the user into a particular variation of an experiment. This function must be called before startOptimizelyWithAPI. If the experimentId or variationId is invalid, there will be no effect. If the relevant data is not downloaded yet, nothing will be done. This function only takes effect if the app is running in normal mode. This function should be used for QA ONLY, since forcing a variation will clear out any saved experiment states for the user.

+ (void)forceVariation:(NSString *)variationId ofExperiment:(NSString *)experimentId

Parameters

variationId

The id of the variation you wish to bucket the user into.

experimentId

The id of the experiment you are bucketing within.

Discussion

DO NOT RELEASE WITH THIS FUNCTION. THIS FUNCTION IS FOR QA PURPOSES ONLY.

Declared In

Optimizely.h

+ disableKillSwitch

Disables the Optimizely Kill Switch

+ (void)disableKillSwitch

Discussion

This method disables the download of the Optimizely kill switch file when called before the Optimizely initialization. Disabling the kill switch file download can speed up startup time, but would disable the Optimizely kill switch feature.

Declared In

Optimizely.h

+ getAttributes

This method returns a copy of all attributes that are defined in the data file. If this is called before Optimizely starts, it will return an empty array. If there are no attributes, it will return an empty array. Each attribute will be an index in the NSArray represented by an instance of the OptimizelyAttribute class.

+ (NSArray *)getAttributes

Declared In

Optimizely.h

+ getAttributeValueForAttributeId:

This method gets the current value of the Optimizely Attribute object with the input attribute Id. If attribute Id is nil, it will return nil. If this method is called before Optimizely is started, it will return what is currently stored. After Optimizely is started, if there is no corresponding OptimizelyAttribute object with that attribute Id, it will return nil.

+ (NSString *)getAttributeValueForAttributeId:(NSString *)attributeId

Parameters

attributeId

The id of the OptimizelyAttribute object whose value is being queried.

Return Value

The value of the OptimizelyAttribute object if found.

Declared In

Optimizely.h

+ getAttributeValueForAttributeApiName:

This method gets the current value of the Optimizely Attribute object with the input attribute API Name. If attribute API Name is nil, it will return nil. If this method is called before Optimizely is started, it will return what is currently stored. After Optimizely is started, if there is no corresponding OptimizelyAttribute object with that attribute API Name, it will return nil.

+ (NSString *)getAttributeValueForAttributeApiName:(NSString *)attributeApiName

Parameters

attributeApiName

The API Name of the OptimizelyAttribute object whose value is being queried.

Return Value

The value of the OptimizelyAttribute object if found.

Declared In

Optimizely.h

+ setValue:forAttributeId:

This method sets the value for a attribute with the corresponding Id. If attributeId is nil, it will return NO. If this method is called before Optimizely is started, it will return YES. It will be unable to check if the attributeId is valid and will only store the key value pair. If this method is called after Optimizely is started, it will return YES if it properly sets the value. If there is no corresponding OptimizelyAttribute, it will return NO.

+ (BOOL)setValue:(NSString *)value forAttributeId:(NSString *)attributeId

Parameters

value

The value to set the OptimizelyAttribute to.

attributeId

The attribute Id of the OptimizelyAttribute you want to modify.

Return Value

YES if the value is successfully set. NO otherwise

Declared In

Optimizely.h

+ setValue:forAttributeApiName:

This method sets the value for a attribute with the corresponding API Name. If attributeApiName is nil, it will return NO. If this method is called before Optimizely is started, it will return YES. It will be unable to check if the attributeApiName is valid and will only store the key value pair. If this method is called after Optimizely is started, it will return YES if it properly sets the value. If there is no corresponding OptimizelyAttribute, it will return NO.

+ (BOOL)setValue:(NSString *)value forAttributeApiName:(NSString *)attributeApiName

Parameters

value

The value to set the OptimizelyAttribute to.

attributeApiName

The attribute API Name of the OptimizelyAttribute you want to modify.

Return Value

YES if the value is successfully set. NO otherwise

Declared In

Optimizely.h

Live Variables

+ stringForKey:

Returns the NSString idenitified by the provided key.

+ (NSString *)stringForKey:(OptimizelyVariableKey *)key

Parameters

key

A key uniquely identifying a live variable

Return Value

The value of this variable in the active experiment (default if no active experiment)

Declared In

Optimizely.h

+ colorForKey:

Returns the UIColor idenitified by the provided key.

+ (UIColor *)colorForKey:(OptimizelyVariableKey *)key

Parameters

key

A key uniquely identifying a live variable

Return Value

The value of this variable in the active experiment (default if no active experiment)

Declared In

Optimizely.h

+ numberForKey:

Returns the NSNumber idenitified by the provided key.

+ (NSNumber *)numberForKey:(OptimizelyVariableKey *)key

Parameters

key

A key uniquely identifying a live variable

Return Value

The value of this variable in the active experiment (default if no active experiment)

Declared In

Optimizely.h

+ pointForKey:

Returns the CGPoint idenitified by the provided key.

+ (CGPoint)pointForKey:(OptimizelyVariableKey *)key

Parameters

key

A key uniquely identifying a live variable

Return Value

The value of this variable in the active experiment (default if no active experiment)

Declared In

Optimizely.h

+ sizeForKey:

Returns the CGSize idenitified by the provided key.

+ (CGSize)sizeForKey:(OptimizelyVariableKey *)key

Parameters

key

A key uniquely identifying a live variable

Return Value

The value of this variable in the active experiment (default if no active experiment)

Declared In

Optimizely.h

+ rectForKey:

Returns the CGRect idenitified by the provided key.

+ (CGRect)rectForKey:(OptimizelyVariableKey *)key

Parameters

key

A key uniquely identifying a live variable

Return Value

The value of this variable in the active experiment (default if no active experiment)

Declared In

Optimizely.h

+ boolForKey:

Returns the BOOL idenitified by the provided key.

+ (BOOL)boolForKey:(OptimizelyVariableKey *)key

Parameters

key

A key uniquely identifying a live variable

Return Value

The value of this variable in the active experiment (default if no active experiment)

Declared In

Optimizely.h

+ registerCallbackForVariableWithKey:callback:

This method registers a callback that is run when the given variable is changed.

+ (void)registerCallbackForVariableWithKey:(OptimizelyVariableKey *)key callback:(void ( ^ ) ( NSString *, id ))callback

Parameters

key

The Optimizely key associated with the variable you want to watch

callback

The callback method that will be invoked whenever the variable is changed. It takes in two parameters, the first being the key of the changed variable and the second is the variable’s new value

Discussion

Method signature is: void (^callback)(NSString *, id)

Declared In

Optimizely.h

Code Blocks

+ codeBlocksWithKey:blockOne:defaultBlock:

This method allows you to define a code block based experiment with one alternative.

+ (void)codeBlocksWithKey:(OptimizelyCodeBlocksKey *)codeBlocksKey blockOne:(void ( ^ ) ( void ))blockOne defaultBlock:(void ( ^ ) ( void ))defaultBlock

Parameters

codeBlocksKey

The OptimizelyCodeBlocksKey associated with this code blocks experiment

blockOne

Block corresponding to the first block name in the provided OptimizelyCodeBlocksKey

defaultBlock

This block will be executed if no active experiment involves this code block key.

Declared In

Optimizely.h

+ codeBlocksWithKey:blockOne:blockTwo:defaultBlock:

This method allows you to define a code block based experiment with two alternatives.

+ (void)codeBlocksWithKey:(OptimizelyCodeBlocksKey *)codeBlocksKey blockOne:(void ( ^ ) ( void ))blockOne blockTwo:(void ( ^ ) ( void ))blockTwo defaultBlock:(void ( ^ ) ( void ))defaultBlock

Parameters

codeBlocksKey

The OptimizelyCodeBlocksKey associated with this code blocks experiment

blockOne

Block corresponding to the first block name in the provided OptimizelyCodeBlocksKey

blockTwo

Block corresponding to the second block name in the provided OptimizelyCodeBlocksKey

defaultBlock

This block will be executed if no active experiment involves this code block key.

Declared In

Optimizely.h

+ codeBlocksWithKey:blockOne:blockTwo:blockThree:defaultBlock:

This method allows you to define a code block based experiment with three alternatives.

+ (void)codeBlocksWithKey:(OptimizelyCodeBlocksKey *)codeBlocksKey blockOne:(void ( ^ ) ( void ))blockOne blockTwo:(void ( ^ ) ( void ))blockTwo blockThree:(void ( ^ ) ( void ))blockThree defaultBlock:(void ( ^ ) ( void ))defaultBlock

Parameters

codeBlocksKey

The OptimizelyCodeBlocksKey associated with this code blocks experiment

blockOne

Block corresponding to the first block name in the provided OptimizelyCodeBlocksKey

blockTwo

Block corresponding to the second block name in the provided OptimizelyCodeBlocksKey

blockThree

Block corresponding to the third block name in the provided OptimizelyCodeBlocksKey

defaultBlock

This block will be executed if no active experiment involves this code block key.

Declared In

Optimizely.h

+ codeBlocksWithKey:blockOne:blockTwo:blockThree:blockFour:defaultBlock:

This method allows you to define a code block based experiment with four alternatives.

+ (void)codeBlocksWithKey:(OptimizelyCodeBlocksKey *)codeBlocksKey blockOne:(void ( ^ ) ( void ))blockOne blockTwo:(void ( ^ ) ( void ))blockTwo blockThree:(void ( ^ ) ( void ))blockThree blockFour:(void ( ^ ) ( void ))blockFour defaultBlock:(void ( ^ ) ( void ))defaultBlock

Parameters

codeBlocksKey

The OptimizelyCodeBlocksKey associated with this code blocks experiment

blockOne

Block corresponding to the first block name in the provided OptimizelyCodeBlocksKey

blockTwo

Block corresponding to the second block name in the provided OptimizelyCodeBlocksKey

blockThree

Block corresponding to the third block name in the provided OptimizelyCodeBlocksKey

blockFour

Block corresponding to the fourth block name in the provided OptimizelyCodeBlocksKey

defaultBlock

This block will be executed if no active experiment involves this code block key.

Declared In

Optimizely.h

+ registerCallbackForCodeBlockWithKey:callback:

This method registers a callback that is run when the given code block is changed.

+ (void)registerCallbackForCodeBlockWithKey:(OptimizelyCodeBlocksKey *)key callback:(void ( ^ ) ( ))callback

Parameters

key

The Optimizely key associated with the code block you want to watch

callback

The callback method that will be invoked whenever the code block is changed.

Discussion

Method signature is: void (^callback)()

Declared In

Optimizely.h

+ ignoreUIViewSubclassesWithNames:

Stores the set of classes that Optimizely will ignore generating OptimizelyIds for.

+ (void)ignoreUIViewSubclassesWithNames:(NSSet *)viewSubclassesToIgnoreForTagging

Parameters

viewSubclassesToIgnoreForTagging

A set of all string class names for which Optimizely will not generate IDs.

Declared In

Optimizely.h

Properties

  allExperiments

This returns a list of OptimizelyExperimentData objects that will encompass all experiments.

@property (readonly, strong, nonatomic) NSArray *allExperiments

Declared In

Optimizely.h

  visitedExperiments

This returns a list of OptimizelyExperimentData objects that will encompass all experiments that the user has viewed across all sessions. To get a list of all experiments, use allExperiments.

@property (readonly, strong, nonatomic) NSArray *visitedExperiments

Declared In

Optimizely.h

  shouldNotGenerateDynamicIds

Whether to dynamically generate optimizelyIds

@property (nonatomic) BOOL shouldNotGenerateDynamicIds

Discussion

By default, Optimizely will generate an id for your views that will allow you to target most views without explicitly setting an optimizelyId. If you’d like the old behavior of only seeing views that are tagged explicitly, set this to YES.

Declared In

Optimizely.h

  projectId

The The current Optimizely project id.

@property (readonly, strong) NSString *projectId

Declared In

Optimizely.h

  sdkVersion

The current SDK version.

@property (readonly, strong) NSString *sdkVersion

Declared In

Optimizely.h

  universalUserId

A unique identifier that can be set. It is used to identify end users across platforms. If a custom identifier is provided, it must be set prior to calling startOptimizelyWithAPIToken. Setting the universalUserId to nil will clear the UUID.

@property (nonatomic, readwrite, strong) NSString *universalUserId

Declared In

Optimizely.h

  optimizelyEndUserId

This is a unique ID generated by the Optimizely SDK. An Optimizely End User ID is assigned to each of the end users who successfully start the SDK.

@property (nonatomic, readonly, strong) NSString *optimizelyEndUserId

Declared In

Optimizely.h

  verboseLogging

When set to true, provides verbose logging details that may be useful for debugging.

@property (nonatomic, readwrite) BOOL verboseLogging

Declared In

Optimizely.h

  dispatchInterval

The frequency (in seconds) at which events are sent to Optimizely and the experiment data file is fetched from server. Defaults to 2 minutes.

@property (nonatomic, readwrite) NSTimeInterval dispatchInterval

Discussion

Setting this to zero or negative value will disable automatic sending of events and you will need to send events manually using dispatch.

Declared In

Optimizely.h

  networkTimeout

NSTimeInterval which controls timeout for first download of config file.

@property (nonatomic, readwrite) NSTimeInterval networkTimeout

Declared In

Optimizely.h

  shouldReloadExperimentsOnForegrounding

Indicates whether experiments should be reloaded on foregrounding. Defaults to true.

@property (nonatomic, readwrite) BOOL shouldReloadExperimentsOnForegrounding

Discussion

By default, Optimizely will activate experiments at two times: the first time an app launches, and when an app is foregrounded. In practice, many app launches are actually foregrounding events as opposed to a full fresh launch. This is because apps are frequently kept in memory and sometimes do not go through a fresh launch for extended periods of time, and so experiments are activated again when foregrounding. Developers should be aware that Optimizely values may change throughout the duration of the app run and that this may have unintended consequences on statistical validity.

If you want to ensure that a user will never have an inconsistent experience as a result of experiment activation, set this value to false so that experiments are only activated when the app launches from a completely clean start. Setting this value to false means that once a view becomes visible, a variable is read, or a code block is executed, its value/appearance will not change for the duration of the app run (applicationDidFinishLaunching:withOptions: is called).

If a foregrounding event results in new experiment data, Optimizely will trigger an NSNotification with the key “OptimizelyNewDataFileLoadedNotification”.

Declared In

Optimizely.h

  disableGesture

BOOL indicating whether or not you want to disable the Optimizely Gesture.

@property (nonatomic, readwrite) BOOL disableGesture

Declared In

Optimizely.h

  startingState

This returns the initialization state of the Optimizely singleton.

@property (nonatomic, readonly) OptimizelyInitializationState startingState

Declared In

Optimizely.h

  mode

Returns the running mode of Optimizely. The default value is OptimizelyRunningModeNormal.

@property (nonatomic, readonly) OptimizelyRunningMode mode

Declared In

Optimizely.h

+ registerPlugin:

Registers the given plugin. This function should be called by the end user if the plugin that they wish to use does not implement auto-registry, or if your project is written in Swift (which lacks macro support). Plugin maintainers should prefer using the OptimizelyRegisterPlugin macro from OptimizelyPlugin.h

+ (void)registerPlugin:(id<OptimizelyPlugin>)plugin

Parameters

plugin

the plugin instance to register. Only one plugin instance should be created.

Declared In

Optimizely.h

Deprecated Methods and Properties

+ getDimensions

@deprecated. Use getAttributes.

+ (NSArray *)getDimensions

Discussion

This method returns a copy of all dimensions that are defined in the data file. If this is called before Optimizely starts, it will return an empty array. If there are no dimensions, it will return an empty array. Each dimension will be an index in the NSArray represented by an instance of the OptimizelyAttribute class.

Declared In

Optimizely.h

– trackEvent:

@deprecated. Use +trackEvent:.

- (void)trackEvent:(NSString *)description

Parameters

description

The string uniquely identifying the custom goal you want to track

Discussion

This method informs the server that a custom goal with key description occured.

See Also

Declared In

Optimizely.h

+ trackRevenue:

@deprecated. Use +trackRevenue: withDescription:.

+ (void)trackRevenue:(int)revenueAmount

Parameters

revenueAmount

The revenue amount in cents associated with the event

Discussion

This method informs Optimizely that a revenue goal custom event occured.

See Also

Declared In

Optimizely.h

– stringForKey:defaultValue:

@deprecated. Use stringForKey:.

- (NSString *)stringForKey:(NSString *)key defaultValue:(NSString *)defaultValue

Parameters

key

A key uniquely defining the variable

defaultValue

The value this variable should take on in the absence of an experimental change

Return Value

The value of this variable in the active experiment (default if no active experiment)

Discussion

This method registers an NSString so that it can be changed via the Optimizely web editor

Declared In

Optimizely.h

– colorForKey:defaultValue:

@deprecated. Use colorForKey:.

- (UIColor *)colorForKey:(NSString *)key defaultValue:(UIColor *)defaultValue

Parameters

key

A key uniquely defining the variable

defaultValue

The value this variable should take on in the absence of an experimental change

Return Value

The value of this variable in the active experiment (default if no active experiment)

Discussion

This method registers an UIColor so that it can be changed via the Optimizely web editor

Declared In

Optimizely.h

– numberForKey:defaultValue:

@deprecated. Use numberForKey:.

- (NSNumber *)numberForKey:(NSString *)key defaultValue:(NSNumber *)defaultValue

Parameters

key

A key uniquely defining the variable

defaultValue

The value this variable should take on in the absence of an experimental change

Return Value

The value of this variable in the active experiment (default if no active experiment)

Discussion

This method registers an NSNumber so that it can be changed via the Optimizely web editor

Declared In

Optimizely.h

– pointForKey:defaultValue:

@deprecated. Use pointForKey:.

- (CGPoint)pointForKey:(NSString *)key defaultValue:(CGPoint)defaultValue

Parameters

key

A key uniquely defining the variable

defaultValue

The value this variable should take on in the absence of an experimental change

Return Value

The value of this variable in the active experiment (default if no active experiment)

Discussion

This method registers an CGPoint so that it can be changed via the Optimizely web editor

Declared In

Optimizely.h

– sizeForKey:defaultValue:

@deprecated. Use sizeForKey:.

- (CGSize)sizeForKey:(NSString *)key defaultValue:(CGSize)defaultValue

Parameters

key

A key uniquely defining the variable

defaultValue

The value this variable should take on in the absence of an experimental change

Return Value

The value of this variable in the active experiment (default if no active experiment)

Discussion

This method registers an CGSize so that it can be changed via the Optimizely web editor

Declared In

Optimizely.h

– rectForKey:defaultValue:

@deprecated. Use rectForKey:.

- (CGRect)rectForKey:(NSString *)key defaultValue:(CGRect)defaultValue

Parameters

key

A key uniquely defining the variable

defaultValue

The value this variable should take on in the absence of an experimental change

Return Value

The value of this variable in the active experiment (default if no active experiment)

Discussion

This method registers an CGRect so that it can be changed via the Optimizely web editor

Declared In

Optimizely.h

– boolForKey:defaultValue:

@deprecated. Use boolForKey:.

- (BOOL)boolForKey:(NSString *)key defaultValue:(BOOL)defaultValue

Parameters

key

A key uniquely defining the variable

defaultValue

The value this variable should take on in the absence of an experimental change

Return Value

The value of this variable in the active experiment (default if no active experiment)

Discussion

This method registers a BOOL so that it can be changed via the Optimizely web editor

Declared In

Optimizely.h

– codeTest:withBlocks:defaultBlock:

@deprecated. Use +codeBlocksWithKey: blockOne:....

- (void)codeTest:(NSString *)codeTestKey withBlocks:(NSDictionary *)blocks defaultBlock:(void ( ^ ) ( void ))defaultBlock

Parameters

codeTestKey

A unique key that describes this test

blocks

A dictionary that maps descriptive NSString keys to (void (^)(void)) blocks for each variation of this test.

defaultBlock

This block will be executed if no active experiment involves this code test.

Discussion

This method allows you to define a code block based experiment

Declared In

Optimizely.h

  )

@deprecated. Use allExperiments or visitedExperiments.

@property (readonly, strong, nonatomic) NSArray *__attribute ( ( deprecated ( "Use allExperiments or visitedExperiments" )

Discussion

Provides an array of all the experiments currently active for the user to the variation they’re bucketed into for that experiment. The metadata includes experiment Id, variation Id, experiment description and variation description.

When an experimenet is viewed, Optimizely will trigger an NSNotification with the key “OptimizelyExperimentVisitedNotification”. The userInfo will have metadata which includes experiment Id, variation Id, experiment description and variation description.

Declared In

Optimizely.h