i have a static class witch has two property,like below …
@interface Global : NSObject
{
BarcodeScanner* scanner;
NSInteger warehouseID;
}
@property(assign) BarcodeScanner* scanner;
@property(assign) NSInteger warehouseID;
+(Global *)sharedInstance;
@end
#import "Global.h"
@implementation Global
@synthesize scanner,warehouseID;
+ (Global *)sharedInstance
{
static Global *globalInstance = nil;
if (nil == globalInstance) {
globalInstance = [[Global alloc] init];
globalInstance.scanner = [[BarcodeScanner alloc] init];
globalInstance.warehouseID = 1;
}
return globalInstance;
}
-(void) dealloc
{
[super dealloc];
}
@end
now when i analyze project in Xcode i got warning for memory leak for scanner and warehouseID properties , and when i try to release them in dealloc method like …
[[[Global sharedInstance] scanner]release];
i got warning “incorrect decrement of the reference count of an object…”
how should i resolve this problem.
so thanks for any help.
The warning is because your code does not match the rules Analyzer uses. To avoid the warning
Example (reformatted just to save space):