6

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.

MCMatan
  • 8,623
  • 6
  • 46
  • 85
  • this question may be help http://stackoverflow.com/questions/20030873/always-pass-weak-reference-of-self-into-block-in-arc – Joe Hallenbeck Aug 05 '15 at 13:48
  • @JoeHallenbeck This does not help, the question to referred is about "When to use weak self". I know when to use is, but some times i just forget and would like the IDE to warn me about it. – MCMatan Aug 05 '15 at 13:56

1 Answers1

0

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

tettoffensive
  • 664
  • 7
  • 24
  • Thanks this is great! were exactly do you have the '-w' written? – MCMatan Aug 08 '15 at 08:58
  • In your project Build Phases go to Compile Sources and on the right column is Compiler Flags. You can put it in there. But you may want to turn if off for third-party libraries – tettoffensive Aug 11 '15 at 01:16
  • 1
    you can multi-select. which i prefer to do to avoid third-party. or i believe on build settings there's "Other Warning Flags" and acutally a whole set of warnings where you can turn them on/off one by one – tettoffensive Aug 11 '15 at 19:12