ARC等同于autorelease? [英] ARC equivalent of autorelease?

查看:175
本文介绍了ARC等同于autorelease?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有此代码,

+ (MyCustomClass*) myCustomClass
{
    return [[[MyCustomClass alloc] init] autorelease];
}

此代码保证返回的对象是自动释放的。
在ARC中相当于什么?

This code guarantees the returning object is autoreleased. What's the equivalent of this in ARC?

推荐答案

ARC中没有等效项,自己做。

There is no equivalent in ARC, as you don't need to do it yourself. it will happen behind the scenes and you are not allowed to do it your self.

您只需使用 -

+ (MyCustomClass*) myCustomClass
{
    return [[MyCustomClass alloc] init];
}

我建议你观看2011年WWDC的ARC介绍,

I suggest you to watch the ARC introduction in the 2011 WWDC as it very simple when you get it.

查看这里:
https://developer.apple.com/videos/wwdc/2011/

电影里的男人说 -

And as the guy in the movie says -


你不必再考虑了(几乎)

You don't have to think about it any more (almost)

这篇关于ARC等同于autorelease?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆