2009-12-11 124 views
-1

分析狀態泄漏問題,爲什麼?潛在泄漏? - 分析儀

+ (DebugOutput *) sharedDebug 
    { 
     @synchronized(self) 
     { 
     if (sharedDebugInstance == nil) 
     { 
      [[self alloc] init]; 
     } 
     } 
     return sharedDebugInstance; 
    } 
+1

我一直想知道爲什麼這樣的問題被標記爲C ... – AnT 2009-12-11 07:09:21

回答

7

好sharedDebugInstance不分配,你可能想這樣做:

sharedDebugInstance = [[self alloc] init]; 
+0

看看這個帖子還有:HTTP ://stackoverflow.com/questions/145154/what-does-your-objective-c-singleton-look-like – nico 2009-12-11 04:17:23