I'm currently doing the following to replace a field's UI with a selection UI.
NSArray *choices = @[@"Alabama", @"Alaska" /* ... */]; SCEntityDefinition *entityDef = [SCEntityDefinition definitionWithEntityName:self.entityName managedObjectContext:context propertyNames:self.propertyNames propertyTitles:self.propertyTitles]; SCPropertyDefinition *stateDef = [entityDef propertyDefinitionWithName:@"State"]; stateDef.type = SCPropertyTypeSelection; stateDef.attributes = [SCSelectionAttributes attributesWithItems:choices allowMultipleSelection:NO allowNoSelection:YES autoDismissDetailView:YES hideDetailViewNavigationBar:NO];
This works, but now I need to change it so that instead of saving the selected index in the underlying model, it saves one of the fields of a dictionary:
NSDictionary *choices = @[ @{@"ID": @1, @"Name": @"Alabama"}, @{@"ID": @2, @"Name": @"Alaska"}, /* ... */ ];
I want the UI to display the Name values in the list, but persist the ID values.
I believe SCPropertyTypeObjectSelection will apply the object instead of the index, but I'm not sure how to persuade it to use the ID from the dictionary. Is there a way?