Is AutoRelease redundant when using ARC in Objective-C?

后端 未结 2 1099
庸人自扰
庸人自扰 2021-01-16 12:13

I\'m pretty new to Objective-C, as you may gather, and until recently, I hadn\'t really understood the need for all this AutoRelease malarky. I think that\'s mostly because

2条回答
  •  梦谈多话
    2021-01-16 13:01

    When using ARC, you do not want to do any memory management yourself. Specifically you will not be calling release and auto release because it does it all for you. In fact, the compiler should probably complain if you try to manage memory yourself.

    Instead of [[[Class alloc] init] autorelease]; you'll just call [[Class alloc] init];

    I recommend reading this blog post for some really good background on ARC and memory management in general.

提交回复
热议问题