So i've got a table view with several sections and i want to make a filter so only a few sections are displayed. I've already created a view so the sections can be chosen. There I've got a table where you can select the wanted sections for the first view. and now i don't know how to use a protocol or delegate to send the data back to my previous view.
so here is the code of the fist view:
and here is the code of the FilterViewController which will be displayed:
and now i want to send this data (selections) back, how do I do this? HELP!
so here is the code of the fist view:
Code:
@implementation TableViewController
- (NSArray *)sections {
if (!sections) {
sections = //creating sections
}
return sections;
}
....
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *settingsButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"Settings" style:UIBarButtonItemStylePlain target:self action:@selector(filterview)];
self.navigationItem.leftBarButtonItem = settingsButtonItem;
[settingsButtonItem release];
}
...
#pragma mark -
#pragma mark Table view delegate
- (void)filterview
{
SettingsTableViewController *settingsTableViewController = [[SettingsTableViewController alloc] init];
[[self navigationController] pushViewController:settingsTableViewController animated:YES];
[sections release];
[settingsTableViewController release];
}
and here is the code of the FilterViewController which will be displayed:
Code:
@implementation SettingsTableViewController
- (NSMutableArray *)selections
{
//here are all selected items saved
if (!selections) {
selections = [[NSMutableArray alloc] init];
}
return selections;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Settings";
self.navigationItem.hidesBackButton = YES;
UIBarButtonItem* saveItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self action:@selector(/*some method to send data back*/)];
self.navigationItem.rightBarButtonItem = saveItem;
[saveItem release];
and now i want to send this data (selections) back, how do I do this? HELP!
Last edited: