objective c - NSDate - How does the default initializer allocate space on the heap? -
i know it's practice explicitly alloc , init objects, i'm confused why not needed instances of nsdate in following example:
nsdate *now = [nsdate date];
appears same this...
nsdate *now = [[nsdate alloc] init];
i assume date class method allocates space on heap, have found nsdate.h , not how apple implemented method.
apple documentation says, "this method uses default initializer method class, init."
+[nsdate date] "convenience constructor". typically implementation similar return [[[self alloc] init] autorelease]
.
Comments
Post a Comment