Cocoa binding and threads.
Cocoa binding and threads.
- Subject: Cocoa binding and threads.
- From: David Burnett <email@hidden>
- Date: Mon, 14 Aug 2006 18:18:00 +0100
Hi,
I'm attempting to multi-thread my Cocoa application which is heavily
based on Cocoa Bindings using Core Data and I'm having GUI update issues.
At the moment it all works fine except that NSTableView that displays
the values from the Entities in the Managed Context does not update on
adding a new entity until either
I click on the window.
Move the mouse over a control that changes the cursor.
Change focus on/off the window.
They worked fine before I started to run this code of a new thread.
I understand that Bindings do not play to well with threads as the GUI
changes occur in the same thread as the value changes, and Cocoa prefers
it GUI changes in the main thread. To this end my thread runs like this
AddRandomGenomeToFlamesUsingContext
createRandomGenomeInContext
RenderThumbnail
createGenomeEntity (on main thread)
addNewFlame (on main thread)
The new Entity is created in createGenomeEntity and one of its values is
changed in AddNewFlame. Both are called using
performSelectorOnMainThread: withObject: waitUntilDone:YES so all of
the changes in the bound values should be performed on the main thread.
AddRandomGenomeToFlamesUsingContext is detached from an Action
responding to a button press.
I've tried calling
[flameTable performSelectorOnMainThread:@selector(setNeedsDisplay)
withObject:nil waitUntilDone:YES];
[flameTable performSelectorOnMainThread:@selector(reloadData)
withObject:nil waitUntilDone:YES];
[oxidizerWindow
performSelectorOnMainThread:@selector(makeKeyAndOrderFront:)
withObject:self waitUntilDone:YES];
at the end of AddRandomGenomeToFlamesUsingContext, all to
no effect, so now I'm totally stumped.
Any ideas ?
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden