I click on a memory leak warning as shown in the screenshot below.
I need to advise how I can solve this memory leak. Can I just do [self release] at the end of the method?
You do not assign the object returned to _sharedUserStockInfo to lose the link and the leak. In this case, _sharedUserStockInfo will remain nil , and the method will also return nil .
_sharedUserStockInfo
nil
+(UserStockInfo*)shareduserStockInfo{ @synchronized([UserStockInfo class]) { if(! _sharedUserStockInfo) _sharedUserStockInfo= [[self alloc]init]; return _sharedUserStockInfo; } return nil; }