|
From: | Maxthon Chan |
Subject: | Re: Question about memory management |
Date: | Fri, 07 Jun 2013 14:29:43 +0800 |
Just asking, with ARC, is this a good choice on implementing singleton? //Singleton.h #import <Foundation/Foundation.h> @interface Singleton : NSObject + (instancetype)defaultSingleton; // … @end extern Singleton *DefaultSingleton // Of course this is optional // Singleton.m Singleton *DefaultSingleton @implementation Singleton + (instancetype)defaultSingleton { if (!DefaultSingleton) DefaultSingleton = [[self alloc] init]; return DefaultSingleton; } // … @end 在 2013-6-7,上午1:31,Ivan Vučica <address@hidden> 写道: It depends on how the object is used -- in this case (without looking at the code), it sounds like it's a typical singleton approach. |
[Prev in Thread] | Current Thread | [Next in Thread] |