Search code examples
objective-cswiftweak-references

Is there a way to show warning on not using weak self?


Every few months, I get the same problem of a ViewController not getting dealloced because of not using weak-self in a block. Is there any way of making Xcode warn me about this?

Thanks.


Solution

  • This might help -Warc-retain-cycles

    Also, if instead of Build, you choose Analyze in Xcode, this will give you more information about bad practices in the code which includes information about using weak variables.

    Another level further is to use Infer, a static analyzer for iOS/Android that Facebook open sourced: www.fbinfer.com

    Also, see: http://fuckingclangwarnings.com/ for other warnings. I just have '-w' set on my project to get all the standard warnings