problem with a custom subclass of uitableview

I am writing a custom subclass of UITableView. I would need this object itself to be its own data source and delegate, and this subclass would then have its own data source and delegate. This is done primarily so I can intercept calls to the datasource and delegate and potentially augment them before sending them off to their actual datasources.

My class is defined as so.

CustomTableView : UITableView<UITableViewDelegate, UITableViewDataSource> {
   ...
   id customDataSource;
   id customDelegate;
}

The problem comes when I try to set my data source and delegate.

I would like to override uitableview's properties:

- (void)setDataSource(id<UITableViewDataSource>)ds {
   [super setDataSource:self]
   customDataSource = ds;
}

Basically, I would like to tell the parent class(UItableView) to set the data source to self. I would then forward any callbacks to the customDataSource, after I have modified them.

[super setDataSource:self] doesnt crash, but the datasource never gets set. Does anyone have any ideas? Thanks

Answers


I ended up not needing to use the method proposed in this question, but I did get it working. The problem was that I had accidentaly synthesized the properties that needed overriding, namely dataSource and delegate.

For people who need to do this in the future, simply override setDelegate and setDataSource in your custom subclass.


Need Your Help

How to display actual image based on file name in sqlite database

android image sqlite imageview android-imageview

I have a local sqlite database file that looks something like this…

MongoDB GridFS Get ID of a file

php mongodb laravel laravel-4 gridfs

I am using MongoDB GridFS to store user avatars. I am using Laravel 4.2.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.