When some codes like this:
objc_setAssociatedObject (
obj,
&key,
val,
OBJC_ASSOCIATION_RETAIN
);
Do I need to call related
objc_setAssociatedObject (
obj,
&key,
nil,
OBJC_ASSOCIATION_RETAIN
);
to release the retained value? Does Objective-C runtime auto release the associative references in dealloc
or somewhere?
Associated objects will be released when the parent object is deallocated. See the documentation here, specifically this example: