• 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: Rapid use of NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rapid use of NSTextField


  • Subject: Re: Rapid use of NSTextField
  • From: Bob Ippolito <email@hidden>
  • Date: Sun, 18 Apr 2004 16:15:45 -0400

On Apr 18, 2004, at 3:49 PM, Justin Bakse wrote:

Hello,
I am working on a project that changes the content of and focus of user editable NSTextFields programaticly. I've noticed that if i rapidly (say 2 dozen times a second) cycle the focus of the the fields sometimes my program stops responding (freezes).

I get this message:
Unlocking Focus on wrong view (<NSView: 0x3338c0>), expected <MyTextField: 0x335d10>

Also, just using [MyNSTextField setIntValue:targetValue]; quickly can cause my program to freeze. I've tested this with just calling setIntValue 4 times in a row in a single call to a function, and this causes a freeze.

An important (i think) factor is that i am doing these changes from a seperate thread, actually they are called as a result of a midi input port proc.

I have reduced the problem by moving the changes to a seperate thread that only updates fields every 1/4 second, based on a variable set in the other thread, but that is sort of messy.

Are there any special precautions i should be using working with NSTextfields (or controls in general) in a threaded app? Any thing else come to mind?

Yes, the special precaution is to not do it at all. You should be calling Cocoa stuff on the main thread and only the main thread. See the performSelectorOnMainThread:.... methods of NSObject.

-bob
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Rapid use of NSTextField
      • From: Sherm Pendley <email@hidden>
References: 
 >Rapid use of NSTextField (From: Justin Bakse <email@hidden>)

  • Prev by Date: Rapid use of NSTextField
  • Next by Date: Re: Rapid use of NSTextField
  • Previous by thread: Rapid use of NSTextField
  • Next by thread: Re: Rapid use of NSTextField
  • Index(es):
    • Date
    • Thread