Starting with Objective-C: To ARC or not to ARC?

前端 未结 5 1478
广开言路
广开言路 2020-12-09 12:43

According to Apple\'s ARC Documentation, there are a fairly significant number of changes to the way that one develops software when using ARC.

As a complete beginne

5条回答
  •  情话喂你
    2020-12-09 13:21

    It's worth noting that ARC is checked by default when you start a new project in Xcode. This is as good a sign as any that the old retain/release way of doing things is deprecated and Apple sees ARC as the future. Your first lesson as a new ObjC developer might be that it never pays to swim up-stream against Apple.

    Also, while it's fairly easy to convert old retain/release samples to ARC (for the most part, just drop any retains, releases, and autoreleases), the inverse is not true. And I've already seen a lot of sample code cropping up that's written ARC-style. So as someone just starting out, it'd pay more to learn the ARC way.

    Note this doesn't mean you don't have to understand reference counting. It's still an important part of an object's life cycle and you still need to be aware of such things (if only to know when to use weak or strong references). But when it comes time to write code, write it with ARC on.

提交回复
热议问题