我已经编写了自己的类(NSObject 的子类),并且还为它编写了一个自定义初始化程序。我遇到的问题是,当我启动应用程序并调用 refreshData 实例方法时,一切正常。然后当我第二次调用 refreshData 方法时,对象被释放并且我得到了错误。当实例初始化时,内存被分配但不知何故被释放。我错过了什么?
UIViewController:
- (void)viewDidLoad {
[super viewDidLoad];
// Initialze an instance of our data controller class
dataController = [FCDataController initWithObject:self animated:NO];
[dataController refreshData];
}
NS对象:
+ (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;
}