简体   繁体   中英

Do we need to release block variable manually in dealloc method under Obj-C ARC mode?

As you know interface vars don't need to be released (self.var = nil) manually in method dealloc() in ARC mode, but how about block variable? If block copy then do we also no need to release it? Have no idea on how to track block var memory leak by instrument.

Anyone who knows please share and thanks in advance.

[block copy] is handled by ARC.

If you use Block_copy then you must use Block_release , but the above form is preferred with ARC.

you may need __weak you variable before put it to block to avoid retain cycle.

See https://developer.apple.com/library/ios/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html for details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM