Associated Objects on Value Types
Greg Parker notes that one should not use objc_setAssociatedObject()
to attach associated objects to immutable value-like types such as NSNumber
, NSDate
, and NSString
. The reason is that, due to de-duplication and tagged pointers, the objects may be shared and/or immortal.
2 Comments RSS · Twitter
January 18, 2014 6:46 AM
There are also classes which you might not think of as value types which are deduplicated, such as UIFont.