ARC equivalent of autorelease?

后端 未结 2 1957
南旧
南旧 2021-02-19 06:30

If I have this code,

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

This code guarantees

2条回答
  •  清歌不尽
    2021-02-19 06:50

    When compiling with ARC, you simply write it as:

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

    and the compiler/runtime will handle the rest for you.

提交回复
热议问题