• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa binding and threads.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa binding and threads.


  • Subject: Re: Cocoa binding and threads.
  • From: David Burnett <email@hidden>
  • Date: Wed, 16 Aug 2006 14:00:05 +0100

Bill Coleman wrote:

Get the NSArrayController that flameTable is bound to and send it a processPendingChanges message.

>I still have to send a displayIfNeeded to the NSTable to get it display >the values
>


Which of course was due to me running it in the child thread, not the main thread, d'oh.

Dave




--- Begin Message ---
  • 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


--- End Message ---
 _______________________________________________
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

References: 
 >Cocoa binding and threads. (From: David Burnett <email@hidden>)
 >Re: Cocoa binding and threads. (From: Bill Coleman <email@hidden>)

  • Prev by Date: Re: SubViews and Events
  • Next by Date: Re: SubViews and Events
  • Previous by thread: Re: Cocoa binding and threads.
  • Next by thread: Re: Cocoa binding and threads.
  • Index(es):
    • Date
    • Thread