No results for ""
EXPAND ALL
  • Home
  • API docs

iOS SDK 5.x to 6.0 migration guide for Objective-C

Read time: 3 minutes
Last edited: Feb 09, 2023

Overview

This topic explains how to adapt Objective-C code that currently uses a 5.x version of the iOS client-side SDK to use version 6.0 or later. The sections in this topic address different changes and updates between versions 5.x and 6.0 of the SDK.

The Objective-C bridging types for the iOS SDK are implemented in Swift, where names are prefixed by Objc. This document refers to the types by the names exposed to Objective-C.

Understanding the new LDValue type

The 6.0 release of the iOS client-side SDK introduces a new type that represents a value of any valid JSON type: LDValue. To learn more, read the generated documentation. You can initialize the LDValue type with different types of values to support arbitrary JSON data.

Here is an example:

Understanding the changes to creating users

The LDUser.custom property has changed in type from NSDictionary<NSString*, id> * _Nullable to NSDictionary<NSString*, LDValue*> * _Nonnull.

Here is an example of the change:

The isEqual function on LDUser has changed. It no longer only compares the key property, and now compares all properties of the instance.

Setting "custom" as a private attribute no longer sets all custom attributes as private. The SDK considers only the custom attribute with the key "custom" as private.

Changes to variation functions

The LDClient functions arrayVariation and dictionaryVariation have been removed. The new jsonVariation function lets you evaluate flags with any value type.

Understanding changes to variationDetail functions

The LDClient functions arrayVariationDetail and dictionaryVariationDetail have been removed. The new jsonVariationDetail function allows evaluating flags with any resultant value type. The LDJSONEvaluationDetail type is used to store the resultant variation and detailed evaluation information.

The reason property of the detailed evaluation result types has also changed from NSDictionary<NSString*, id> * _Nullable to NSDictionary<NSString*, LDValue*> * _Nullable.

Understanding the changes to flag value observers

The LDClient previously provided per-type functions for registering observers for flag values. These have been replaced with a single observe function you can use with flag variations of any JSON type.

Recording custom events

If your application uses track to record custom events, you must remove the error parameter. The track functions no longer have the potential to error from invalid custom event data, because the data parameter is now restricted to the LDValue type. Change provided data types to LDValue instances.

Here is an example of the required changes: