ARC, worth it or not?

前端 未结 7 1539
没有蜡笔的小新
没有蜡笔的小新 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:14

    1. If you're using Core Foundation or non-Objective-C code, then it's not as simple as you will have to manually go through your code and make sure all the casts between Objective-C and Core Foundation are bridged (if you have any casts). You'll also still have to manage memory for non-Objective-C code.

    2. It's supposed to essentially take care of all memory leaks for you, since it automates the retain, release, copy, etc. So far, I've never had an Objective-C leak since switching to ARC.

    3. No. Building might take a tad bit longer since it has to go through all your code and insert all the retain and release code.

    4. Not sure if there are any. In the end, all ARC is, is an automator.

    5. You will have to learn about bridged casts as well as you cannot build for anything lower than iOS 4.

    In the end, it's definitely worth it. I was skeptical at first, but after watching the WWDC video where they explain how it works, I liked it more and more.

提交回复
热议问题