• 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: Blocking for input during a loop?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Blocking for input during a loop?


  • Subject: Re: Blocking for input during a loop?
  • From: Kyle Sluder <email@hidden>
  • Date: Sun, 17 Jan 2010 21:29:32 -0800

On Sun, Jan 17, 2010 at 1:59 PM, Per Bull Holmen <email@hidden> wrote:
> Is it possible, in Cocoa, do program a loop which goes something like this:
>
> for i=1 to 20
> do something
> block for GUI user input
> do something with the input
> repeat

This is a bad idea. Don't block the UI thread, because then the user
will see a beachball.

Sounds like you need to reread the Cocoa Event Handling Guide:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/Introduction/Introduction.html

Your architectural difficulties also betray an unfamiliarity with MVC
design. I suggest you read the Cocoa Design Patterns section of the
Cocoa Fundamentals Guide, delve into the AppKit classes to see how
that document relates to the actual framework, and then iterate your
own design over and over (perhaps with pencil and paper for a while),
keeping in mind the things you've learned from the documentation and
from using the classes in AppKit. AppKit classes need to maintain a
lot of state information, particularly when doing things like dragging
or other input-driven processes. Here is the relevant document:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW6

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Blocking for input during a loop?
      • From: Per Bull Holmen <email@hidden>
References: 
 >Blocking for input during a loop? (From: Per Bull Holmen <email@hidden>)

  • Prev by Date: Re: Crash on Snow Leopard in _LSAcquireIconRefForURL
  • Next by Date: Re: Crash using IKImageBrowserView
  • Previous by thread: Blocking for input during a loop?
  • Next by thread: Re: Blocking for input during a loop?
  • Index(es):
    • Date
    • Thread