I am trying to assign the datasource
to a datasource
property of a custom UIView
which has a UITableView
subView
. The code is as followed:
CustomUIView.m
- (void)setDataSource:(id<UITableViewDataSource>)dataSource
{
self.dataSource = dataSource;
if (!self.tableView) {
[self createTableView];
[self setUpTableViewSizeAndAddToSuperView];
}
self.tableView.dataSource = self.dataSource;
}
CustomUIView.h
@property (nonatomic, strong) id<UITableViewDataSource> dataSource;
The datasource is provided in a property called delegateobject in a UIViewController.
UIViewController.m
self.customView.dataSource = delegateobject;
UIViewController.h
@property (nonatomic, strong) DelegateObject *delegateobject;
DelegateObject is just a NSObject
with UITableViewDataSource
protocol.
But when I ran the app it gave me the EXEC_BAD_ACCESS
error and crashed.
The datasource
property of my custom UIView
has been released too many times and stopped at this line:
self.dataSource = dataSource;
I have enabled zombie objects diagnosis but couldn't see any additional information. How can I fix this?