I created an object and tell the EODisplayGroup to select it but nothing is selected

From EOFWiki
Jump to: navigation, search

Description

In your code, you are doing something like:

  foo = [bar createFooOnDemandTooComplexlyForEODisplayGroup];
  [fooDisplayGroup selectObject:foo];

On the UI you see that the foo object appears in the EODisplayGroup (showing foo children of bar), but it is not selected.


How to fix it

What bites you in the ass, is that in EOF the processing of the model data is aggregated at the end of the NSRunLoop and then pushed to the User Interface. But your code is executing well ahead of this. So the edit has not influenced the EODisplayGroup yet, and the new object is yet unknown to this EODisplayGroup.

In cases like this, you have two options. Delay the selection to after the NSRunLoop:

  [fooDisplayGroup performSelector:@selector( selectObject:) 
                        withObject:foo 
                        afterDelay:0.01];

or force an intermediate processing of the changes in both the model layer (EOControl) and the user interface layer (EOInterface)

 [editingContext processRecentChanges];  // push info to DisplayGroups
 [[EODelayedObserverQueue defaultObserverQueue] notifyObserversUpToPriority:EOObserverPrioritySixth]; // work DisplayGroups

If you find yourself employing this on a regular basis, then I am afraid as an EOF coder, you are doing it wrong.

Personal tools