here is code
+ (SalesCollection*)sharedCollection {
@synchronized(self) {
if (sharedInstance == nil) {
[[self alloc] init]; // assignment not done here
}
}
return sharedInstance;
}
+ (id)allocWithZone:(NSZone *)zone {
@synchronized(self) {
if (sharedInstance == nil) {
sharedInstance = [super allocWithZone:zone];
return sharedInstance; // assignment and return on first allocation
}
}
return nil; //on subsequent allocation attempts return nil
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
- (id)retain {
return self;
}
- (unsigned)retainCount {
return UINT_MAX; //denotes an object that cannot be released
}
- (void)release {
/* Problem in Here */
[myDict release];
sharedInstance = nil;
[sharedInstance release];
}
- (id)autorelease {
return self;
}
// setup the data collection
- init {
if (self = [super init]) {
[self setupData];
}
return self;
}
and here my .h file
@interface MyCollection : NSObject {
NSMutableDictionary *myDict;
}
@property (nonatomic,retain) NSMutableDictionary * myDict;
+ (MyCollection*)sharedInstance ;
- (void)setupData;
and i have one NSMutableDictionary (myDict) which contains array of object. now my problem is i want to refresh this data on button click. so i am releasing this instance in - (void)release method then try to Init again but that creates lots of leaks because may it does not release array of objects form the myDict so how to achieve this. i follow same example "TheElement" from apple to create singleton.
Thanks