Can an Objective-C block object have an associated object?
If it can, are there a开发者_运维问答ny gotchas to using it?
Yes you can. I just tried it. This makes sense, since blocks are instances of NSBlock
(a private class), which itself inherits from NSObject
.
However, my naïve test seemed to indicate that the associated object was not un-associated when the block was deallocated. (Although it's possible that I was never hitting the block's -dealloc
method)
I'll keep experimenting and try some more stuff.
精彩评论