ObjcLDContext

@objc(LDContext)
public final class ObjcLDContext : NSObject

LDContext is a collection of attributes that can be referenced in flag evaluations and analytics events.

To create an LDContext of a single kind, such as a user, you may use LDContextBuilder.

To create an LDContext with multiple kinds, use LDMultiContextBuilder.

  • FullyQualifiedKey returns a string that describes the entire Context based on Kind and Key values.

    This value is used whenever LaunchDarkly needs a string identifier based on all of the Kind and Key values in the context; the SDK may use this for caching previously seen contexts, for instance.

    Declaration

    Swift

    @objc
    public func fullyQualifiedKey() -> String
  • Declaration

    Swift

    @objc
    public func isMulti() -> Bool

    Return Value

    true if the LDContext is a multi-context; false otherwise.

  • / - Returns: A hash mapping a context’s kind to its key.

    Declaration

    Swift

    @objc
    public func contextKeys() -> [String : String]
  • Looks up the value of any attribute of the LDContext, or a value contained within an attribute, based on a Reference. This includes only attributes that are addressable in evaluations.

    This implements the same behavior that the SDK uses to resolve attribute references during a flag evaluation. In a context, the Reference can represent a simple attribute name– either a built-in one like “name” or “key”, or a custom attribute that was set by LDContextBuilder.trySetValue(...)– or, it can be a slash-delimited path using a JSON-Pointer-like syntax. See Reference for more details.

    For a multi-context, the only supported attribute name is “kind”.

    If the value is found, the return value is the attribute value, using the type LDValue to represent a value of any JSON type.

    If there is no such attribute, or if the Reference is invalid, the return value is nil.

    Declaration

    Swift

    @objc
    public func getValue(reference: ObjcLDReference) -> ObjcLDValue?