First post on the forum

I have an issue with an objectselection and its detailview. Since there are a number of values to chose from in the detail view I need a way to structure it and make it easy for the user to find the right one. In other words I need a search feature or an index. Usually, this is easy to accomplish using the SCArrayofObjectsModel, but since, this one is inside an automatically loaded detailview it seems to be much harder.
I did try to load a custom detail view (see code below) but I can't get it to return a value that the main view accepts.
I think I've tried everything but I can't get it right. I would appreciate if someone could point me in the right direction or, even better, provide me some easy code example on how to bind the selected object on detail view to the objectSelectionCell on the main view.
main.h
@class DetailView; @interface ObjectiveWizard : SCViewController <SCTableViewControllerDelegate,SCTableViewModelDataSource,SCTableViewModelDelegate> @property (strong, nonatomic) DetailView *detailView; @end
main.m (the interesting parts)
SCPropertyDefinition *myProperty = [entityPropDef propertyDefinitionWithName:@"property"]; myProperty.type = SCPropertyTypeObjectSelection; SCObjectSelectionAttributes *attr = [SCObjectSelectionAttributes attributesWithObjectsEntityDefinition:secondEntityList usingPredicate:nil allowMultipleSelection:NO allowNoSelection:NO]; attr.autoDismissDetailView = YES; attr.allowAddingItems = YES; myProperty.attributes = attr; myProperty.required = YES; myProperty.cellActions.detailViewController = ^UIViewController*(SCTableViewCell *cell, NSIndexPath *indexPath) { DetailView *customVC = [[DetailView alloc] initWithNibName:@"DetailView" bundle:nil]; return customVC; }; SCArrayOfObjectsSection *section = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil entityDefinition:entityPropDef]; section.allowEditDetailView = YES; section.allowAddingItems = YES; section.allowDeletingItems = YES; section.allowMovingItems = NO;
And DetailView.h
#import "MainView.h" @interface DetailView : SCViewController <SCTableViewControllerDelegate,SCTableViewModelDataSource,SCTableViewModelDelegate> @end
DetailView.m
- (void)viewDidLoad { [super viewDidLoad]; ............ ............ self.navigationBarType = SCNavigationBarTypeDoneRightCancelLeft; SCSelectionModel *selectionModel = [[SCSelectionModel alloc] initWithTableView:self.tableView entityDefinition:secondEntityList filterPredicate:nil]; selectionModel.autoSortSections = TRUE; selectionModel.allowAddingItems = YES; selectionModel.allowDeletingItems = YES; selectionModel.allowMovingItems = NO; selectionModel.allowEditDetailView = NO; selectionModel.modelActions.sectionHeaderTitleForItem = ^NSString*(SCArrayOfItemsModel *itemsModel, NSObject *item, NSUInteger itemIndex) { .... Header titles .... return [objectName capitalizedString]; }; self.tableViewModel = selectionModel; }
The custom detailViewcontroller gets called and filled with values, but I can't return from that view in any other way than to press cancel. If I select a value and press done, the app crash with a "unrecognized selector" error (seems to be due to selectedItemsindex.
If anyone could guide me on how to accomplish this i would really appreciate it!
Thank you for your time!
Alex
Edited by Alexander Ekdahl, 05 March 2013 - 08:06 AM.