Re: UIView/NSView doesn't display changing data in real time
Re: UIView/NSView doesn't display changing data in real time
- Subject: Re: UIView/NSView doesn't display changing data in real time
- From: "Hank Heijink (Mailinglists)" <email@hidden>
- Date: Tue, 19 Apr 2011 14:07:51 -0400
On Apr 19, 2011, at 1:51 PM, Frederick C. Lee wrote:
> Greetings:
>
> Simple scenario: background thread is computing data to be displayed in real time within the main thread.
> Data: dynamic/variable data that is converted into a NSString type within a background thread, displayed within a UILabel (or NSLabel) on the main thread.
>
> My own environment: iOS 4+ (relevant to OS X as well) using Xcode 4+.
>
> Design: background thread (via NSOperation/NSOperationQueue) sends data/iteration to the main (host) thread via DELEGATION.
I wonder why you need to send data to the main thread. Can't the main thread just inspect a shared data structure (appropriately locked of course) whenever it needs to update the UI? However, without knowing what you're trying to do it's hard to comment on the design - you may well have picked the best choice here. What is your data frequency?
> Note: the main thread *** sees **** this data in read time (via NSLog() stmt )....
>
> However, the front end UIView (or NSView) does NOT update/iteration in real time.
How are you updating the view? How real time is real time? What are you observing that leads you to believe you're looking at the wong data, i.e. is it delayed, or complete garbage?
> Paradigm Request: a real-time digital clock.... tick, tick... you see the seconds being updated. I need to ditto that with velocity, position, etc.
> I tried the 'setNeedsDisplay' method call; has no effect.
If you just need to display text, I'd use a UILabel where you keep updating the text property. If you use a custom UIView you'll need to call setNeedsDisplay and have your drawRect: method update the view appropriately.
> Question: What is the preferred way to display within the MAIN thread in real time, data that is computed on a back-end thread?
That very much depends on how much data you have and how frequently the UI needs to be updated. Hard to say without more info - there are lots of possibilities.
Hank_______________________________________________
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