Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-07-2010, 01:06 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 3
grzesiek is on a distinguished road
Question UIView setNeedsDisplay with NSThread/NSTimer

Hi!

I have UIView, which shows simple line chart (it's drawing in drawRect method with CGContext methods). I want refresh this chart between 5 seconds while UIView is visible. How can I do this? Could you show me very simple code example?

I'm asking for that, because when I'm using timer with [self setNeedsDisplay] my app cause crash sometimes (and debugger console is empty). I was trying call [self setNeedsDisplay] with [self performSelectorOnMainView....] and [NSThread detachNewThreadSelector..] and [self performSelector.. withObject... afterDelay...].. every time my app is crashing..

Sorry for my poor language.

Regards,
Greg
grzesiek is offline   Reply With Quote
Old 07-07-2010, 01:26 PM   #2 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

You can only call UI methods from the main thread. Calling then from any other thread will crash. Look into performSelectorOnMainThread if you need to trigger the call from another thread.
JasonR is offline   Reply With Quote
Old 07-07-2010, 01:47 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 3
grzesiek is on a distinguished road
Default

So, I should use something like that: [self performSelectorOnMainThread:@selector(setNeedsDisp lay) withObject:nil waitUntilDone:YES] ? Can I use this in thread fired with same UIView?
grzesiek is offline   Reply With Quote
Reply

Bookmarks

Tags
nsthread, refresh drawing, setneedsdisplay

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 329
9 members and 320 guests
bignoggins, Chickenrig, firecall, givensur, iNet, michaelhansen, Objective Zero, PlutoPrime, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,893
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:34 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0