Skip to content
NickyWeber edited this page Sep 26, 2014 · 4 revisions

To integrate unfinished features into the mainline branch develop, you can use the class FeatureToggle. The idea is to hide new features by asking the FeatureToggle instance if the feature is enabled or not. Not every part of the feature code should be guarded by this condition. The idea is to integrate as much code as possible without letting the user use the unfinished product. A good way is to hide UI elements which would show up to let a user use the feature. When a feature is finished and integrated the Feature Toggle has to be removed. The Feature Toggle comes with a shared instance and can be initialized separately if ever needed.

###If statement example for the packages feature:

    if (![FeatureToggle sharedFeatures].arePackagesEnabled)
    {
        [menuPlusButtonNewPackage setHidden:YES];
        [menuFileNewPackage setHidden:YES];
    }

To add a feature to be toggled add a property to the Feature Toggle class. To test code which might be guarded by the Feature Toggle set the feature property to YES.

###Example property packages feature

@property (nonatomic, getter=arePackagesEnabled) BOOL packages;

The feature toggle singleton is configured by a property list configuration Resource/Features.plist. The name for the feature has to match the property name. KVC is used to set it. There won't be any exceptions thrown if a feature is provided by the config but not a corresponding property found in the class. A warning will be dumped on the console.

Structure of the property list is just a dictionary with the feature's name as a key and BOOL value:

<dict>
	<key>packages</key>
	<true/>
</dict>

Later on new features should be toggled by the userdefaults, which is not yet implemented.

Feature Toggling

Clone this wiki locally