• 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: Threads, safeness, and AutoreleasePools
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threads, safeness, and AutoreleasePools


  • Subject: Re: Threads, safeness, and AutoreleasePools
  • From: Rainer Brockerhoff <email@hidden>
  • Date: Wed, 15 Aug 2001 10:34:43 -0300

>Date: Wed, 15 Aug 2001 09:03:42 +0200
>From: Raphael Sebbe <email@hidden>
>
>On Wednesday, August 15, 2001, at 04:59 AM, Todd Heberlein wrote:
>
>> I have been experimenting with NSThreads, and I had a couple
>> questions. At
>> the bottom is a sample method I am testing. It is executed in a new
>> thread
> > with the detachNewThread:Selector:toTarget:withObject: method.
>>
>> First, does Apple discourage us from sending a message to an AppKit
>> object
>> from a separate thread? For example, in the code below I send the
>> setIntvalue to an NSTextField object. Is this OK? Are there other
>> steps I
>> should do?
>
>This is not OK. Only the main thread can access GUI objects.
>
>You have a number of solutions to do that : DO (see NSConnection doc),
>NSPort and NSPortMessage, AppleEvents, pipes...

Simply use:
[NSApplication detachDrawingThread:toTarget:withObject:]
instead of
[NSThread detachNewThread:Selector:toTarget:withObject:]
this will allow your detached thread to set GUI object's values.


--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
http://www.brockerhoff.net/ (updated July 2000)


  • Prev by Date: Re: NSImage in NSTableView looks like poop
  • Next by Date: Re: References, etc. for learning Cocoa?
  • Previous by thread: Re: Threads, safeness, and AutoreleasePools
  • Next by thread: Re: Threads, safeness, and AutoreleasePools
  • Index(es):
    • Date
    • Thread