iOS Proper Use of @weakify(self) and @strongify(self)

后端 未结 3 889
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 21:17

I\'m starting to integrate libextobjc (https://github.com/jspahrsummers/libextobjc) into my iOS application primarily to take advantage of EXTScope\'s @strongify an

3条回答
  •  野的像风
    2021-01-29 21:41

    To answer your question of whether multiple instances of weakify/strongify in each nested level of your blocks works, then yes. But there's no need to do that because, your first @strongify definition already defines self for all of the inner scope of your block (and the blocks that are nested in it).

    However, given that your blocks have different lifetimes, you might want to add @strongify for each nested block to make sure they all hold their own retain cycle to their inner scope.

    Here's the github issue thread that explains this case: https://github.com/jspahrsummers/libextobjc/issues/45

提交回复
热议问题