- I created a single view project in
Xcode
which by default includesViewController
file. - I created a
NSObject
subclass namedMyClass
. - I
#import <UIKit/UIKit.h>
inMyClass
. MyClass
confirms toUITableViewDelegate
andUITableViewDatasource
- Implemented the required methods of
UITableViewDelegate
andUITableViewDatasource
- I created a
xib
file, and in UIView I dragged dropped theUITableView
. - I set the xib file
files owner
class toMyClass
. - Set the
UITableView
delegate and datasource in xib file. In
ViewController
viewDidAppear
I did thisUIView *subView1=[[[NSBundle mainBundle] loadNibNamed:@"View1" owner:self options:nil] objectAtIndex:0]; MyClass *c = [[MyClass alloc]init]; [self.view addSubview:subView1];
But I am getting this error on [self.view addSubview:subView1];
-[ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x10027adc0
In xcode console I did po 0x10027adc0
which is ViewController
I am trying to create a functionality of UITableView using xib file
and NSObject
subclass so I can reuse it where ever I want in UIViewController
class.
What I am doing wrong?