I'm building an iPad app with storyboards. I have a "data page" (view) where I put one big container with a tableview which contains data. then I have 3 small containers above, also with tableviews, those should filter the data on the big container. In IB connected all tableviews with embed segues. Visually, it already builds exactly how I need to, all tables shown with content. so far so good.
now the communication part: for each "filter tableview" I implement a protocol method and delegate property, and conformed the "data" container tableview controller to it. But somehow the methods are not being called. I tried setting [self setDelegate:self] in the filter tableview controller, but that crashes the app with ": unrecognized selector sent to instance"
It's not my first delegate protocol, in my other (working) case I programmatically instantiate a view and needed to set the delegate to that view. How is it done here???
A following question would be: to conform my data container viewcontroller to 3 delegates, I just set 3 different type id properties? (meaning, calling them differently?)
Any hint hugely appreciated!
Edit: Code added. [filter:selection:] is not being called... no NSLogs..
//MainDataViewController.h
@interface MainDataViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource,FilterDelegate>
-(void)filter:(Object *)filterObject selecting:(BOOL)selection;
@end
//MainDataViewController.m
#import "MainDataViewController.h"
#import "FilterViewController.h"
@interface MainDataViewController ()
@end
@implementation MainDataViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
}
- (void)filter:(Object *)filterObject selecting:(BOOL)selection;
{
NSLog(@"test");
NSLog(@"selection object: %@", filterObject);
}
@end
//FilterViewController.h
@protocol FilterDelegate <NSObject>
- (void)filter:(Object *)filterObject selecting:(BOOL)selection;
@end
@interface FilterViewController : UITableViewController <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, weak) id <FilterDelegate> delegate;
@end
//FilterViewController.m
#import "FilterViewController.h"
@interface FilterViewController ()
@end
@implementation FilterViewController
@synthesize delegate;
- (void)viewDidLoad
{
[super viewDidLoad];
[self setDelegate:self];
[self.tableView setDelegate:self];
[self.tableView setDataSource:self];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
}
[self.delegate filter:object selecting:YES];
}