I have written my own class (subclass of a NSObject) and have also written a custom initializer for it. The problem I am running into is, when I start my application, and call the refreshData instance method, everything works as it should. When I then call the refreshData method for a second time, the object is deallocated and I get the error. When the instance is initialized, the memory is allocated but somehow it is being deallocated. What am I missing?
UIViewController:
- (void)viewDidLoad {
[super viewDidLoad];
// Initialze an instance of our data controller class
dataController = [FCDataController initWithObject:self animated:NO];
[dataController refreshData];
}
NSObject:
+ (FCDataController *)initWithObject:(id)object animated:(BOOL)animated {
FCDataController *dataController = [[FCDataController alloc] initWithObject:object animated:animated];
return dataController;
}
- (id)initWithObject:(id)object animated:(BOOL)animated {
self = [super init];
if (self) {
self.delegate = object;
self.animated = animated;
}
return self;
}