潜在泄漏? - 分析仪

nil*_*nil -1 c iphone objective-c

分析状态泄漏问题,为什么?

+ (DebugOutput *) sharedDebug
    {
      @synchronized(self)
      {
        if (sharedDebugInstance == nil)
        {
          [[self alloc] init];
        }  
      }
      return sharedDebugInstance;
    }
Run Code Online (Sandbox Code Playgroud)

nic*_*ico 7

好的sharedDebugInstance没有分配,你可能想这样做:

sharedDebugInstance = [[self alloc] init];
Run Code Online (Sandbox Code Playgroud)