Do I need to explicitly alloc my NSNumber?

后端 未结 3 594
小蘑菇
小蘑菇 2020-12-31 16:17

I am defining a number, as follows:

NSNumber *nn0 = [NSNumber numberWithInt:0];

It works fine without any alloc. My understanding is that i

3条回答
  •  情话喂你
    2020-12-31 17:01

    The "convenience constructors" for a lot of types produce an object that is automatically "autoreleased" - i.e. the new object will be retained by the current NSAutoreleasePool. You don't need to manually release these objects - they will be released when the current NSAutoreleasePool is released/drained.

    See this page for a description of convenience constructors, and how to mange the memory for these.

    http://www.macdevcenter.com/pub/a/mac/2001/07/27/cocoa.html?page=3

提交回复
热议问题