Can an Objective-C object have an associated object?

If possible, are there any problems with its use?

+4
source share
1 answer

Yes, you can. I just tried it. This makes sense because the blocks are instances of NSBlock (a private class), which itself inherits from NSObject .

However, my naive test seemed to indicate that the linked object was not bound when the block was freed. (Although it is possible that I never pressed the -dealloc block method)

I will experiment and try something else.

+3
source

Source: https://habr.com/ru/post/1342349/


All Articles