Objective-C memory management, xml parser and other non-trivial examples

前端 未结 6 1591
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 18:00

I know the basic principles about memory management (retain count, autorelease pools etc) in Cocoa, but once you go past simple retain/release, it\'s getting a bit more confusin

6条回答
  •  礼貌的吻别
    2021-02-04 18:36

    Static Analyzer

    In addition to: Memory Management Programming Guide for Cocoa , Static Analyzer is an indispensable tool.

    Project->Project Settings->Build->Build Options->Run Static Analyzer

    Make sure that it is ticked.

    It will tell you all memory allocation errors you are doing. So, you will understand better how to create objects, double-autorelease errors, double-release errors, referring to released objects, etc.

    I read the memory management principles many times but did not get it until I used the Static Analyzer.

    Now I am better at this and get it right most of the time. Static Analyzer, however, is still essential because it points out mistakes and missed ones.

    Yoichi

提交回复
热议问题