How can I persist NSPredicateEditor NSPredicateEditorRowTemplates data

150 views Asked by At

I've been struggling with getting the information entered in an NSPredicatEditor from session to session in a Swift project.

Any guidance or samples would be greatly appreciated.

What I've got so far.

  1. A predicate editor that is functional implemented in an Action Sheet.
  2. Bound predicate to an NSArrayController also bound to a CoreData Table.
  3. A method to generate Row Templates based on CoreData Table Attributes.

What is not working.

  • A bound predict variable to the predicateditor getting error on not being able to match the predicate to a row template also at the awakefromnib seems to be where this is checked the row templates are not initialised (nil )at this point from the InterfaceBuilder

What I want to be able to do Using the NSUSerDefaults persist the contents of the predicate editor so that when the application is re-started this editor has the data last entered.

1

There are 1 answers

0
pkamb On

Load the previously saved predicate by setting the editor's objectValue property.

predicateEditor.objectValue = predicate

After setting up the predicate editor, you typically send it a objectValue message to restore a saved predicate. source

It sounds like you may have a complicated setup involving Interface Builder, array controllers, Core Data, bindings, etc. Try it through code instead: load the row templates, then load the predicate.