From 392c1e5c5579b1b58e02acddf2880097d9e1e0ce Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 16 Mar 2010 13:22:06 +0000 Subject: Modify our current implementation of all singleton instances to be inline with Apple's recommendations detailed at http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32 This also fixes the associated static analysis warnings of potentially leaked objects. --- Source/SPLogger.m | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'Source/SPLogger.m') diff --git a/Source/SPLogger.m b/Source/SPLogger.m index 9d8f7a92..d492fe32 100644 --- a/Source/SPLogger.m +++ b/Source/SPLogger.m @@ -47,7 +47,7 @@ static SPLogger *logger = nil; { @synchronized(self) { if (logger == nil) { - [[self alloc] init]; + logger = [[super allocWithZone:NULL] init]; } } @@ -60,16 +60,20 @@ static SPLogger *logger = nil; + (id)allocWithZone:(NSZone *)zone { @synchronized(self) { - if (logger == nil) { - logger = [super allocWithZone:zone]; - - return logger; - } + return [[self logger] retain]; } - - return nil; } +- (id)copyWithZone:(NSZone *)zone { return self; } + +- (id)retain { return self; } + +- (NSUInteger)retainCount { return NSUIntegerMax; } + +- (void)release {} + +- (id)autorelease { return self; } + - (id)init { if ((self = [super init])) { -- cgit v1.2.3