Objective-C Associated Objects

suggest change

Introduction

First introduced in iOS 3.1 as part of the Objective-C runtime, associated objects provide a way to add storage to an existing object without subclassing.

This means you can attach any object to any other object without subclassing.

Syntax

Parameters

Param Details
object The existing object you want to modify
key A pointer with a stable address. A common choice is the address of a static variable.
value The object you want to add
policy The memory policy for this new value: retain, assign, or copy, as with any other property

Remarks

More details here:

NSHipster

@kostiakoval

kingscocoa

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents