Returns the value associated with a given object for a given key.


func objc_getAssociatedObject(_ object: Any, _ key: UnsafeRawPointer) -> Any?



The source object for the association.


The key for the association.

Return Value

The value associated with the key key for object.

See Also

Associative References

func objc_setAssociatedObject(Any, UnsafeRawPointer, Any?, objc_AssociationPolicy)

Sets an associated value for a given object using a given key and association policy.

func objc_removeAssociatedObjects(Any)

Removes all associations for a given object.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software