ARC, worth it or not?

前端 未结 7 1599
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 09:53

When I moved to Objective C (iOS) from C++ (and little Java) I had hard time understanding memory management in iOS. But now all this seems natural and I know retain, autoreleas

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 10:07

    Have you read Apple's documentation on ARC? It answers a lot of the questions you're asking.

    Based on my experience, here's what I think:

    1. Yes, it's simple. You definitely need to test your app after converting, though.
    2. It can help reduce your app's memory usage and leaks, but it's not guaranteed to do that.
    3. Yes. You'll want to test after converting to ARC.
    4. You don't have to waste as much time thinking about and tracking down leaks. You can spend more time and energy on your app's actual code, rather than worrying about retain/release. Even if retain/release code is natural and easy for you, you're not infallible and you'll occasionally forget to release something. ARC doesn't forget.
    5. If you're supporting iOS 4, you'll have to handle weak references, as ARC doesn't support those in iOS 4.

提交回复
热议问题