Questions tagged [runloop]

A run loop is the concept of running a local loop waiting for a specific event or timeout.

A run loop is the concept of running a local loop waiting for a specific event or timeout.

Such a loop keeps the current thread busy and does not return until the loop has finished, which can either be by a timeout value, an explicit stop signal or if there are no events to process anymore (depends on the specific implementation). Message pumps/loops in applications to process incomming events are typical run loops. But there are other types of local loops (e.g. to make an originally asynchronous process synchronous).

126 questions
44
votes
10 answers

Is there a way to make drawRect work right NOW?

If you are an advanced user of drawRect, you will know that of course drawRect will not actually run until "all processing is finished." setNeedsDisplay flags a view as invalidated and the OS, and basically waits until all processing is done. This…
Fattie
  • 27,874
  • 70
  • 431
  • 719
34
votes
5 answers

How to, simply, wait for any layout in iOS?

Before beginning note that this has nothing to do with background processing. There is no "calculation" involved that one would background. Only UIKit. view.addItemsA() view.addItemsB() view.addItemsC() Let's say on a 6s iPhone EACH of these takes…
Fattie
  • 27,874
  • 70
  • 431
  • 719
28
votes
1 answer

iOS Games and Run-Loop Management

First, my question: How do you manage your iOS Run-Loop? Next my reason: I've been researching this with a variety of prototypes (v. early stage development) and have found a number of perplexing issues. First, input issues and the run loop lead me…
Mark
  • 411
  • 4
  • 8
18
votes
2 answers

Is NSTimer expected to fire when app is backgrounded?

I don't understand it at all but NSTimer in my app definitely is running in background. I have a NSLog in method run by the timer and it is logging while it's in background. It's on iPhone 4 with iOS 4.2.1. I have declared location background…
JakubM
  • 2,685
  • 2
  • 23
  • 33
17
votes
3 answers

Is there any guide for iOS runloop mechanism?

I'm learning socket communication on iPhone, and its guide said something about CFRunloop(it is a guide for CFNetwork, can this be used on iOS?) Where can I learn about runloop on iOS?API reference is not enough.
CarmeloS
  • 7,868
  • 8
  • 56
  • 103
9
votes
5 answers

Enqueue a selector to the run loop - is [NSObject performSelector:withObject:afterDelay:] the way to go?

I'd like to have a method be executed after the current method has passed and the UI has been updated. For that purpose, I'm using [object performSelector:@selector(someSelector) withObject:someObject afterDelay:0.0] right now. According to Apple's…
MrMage
  • 7,282
  • 2
  • 41
  • 71
7
votes
2 answers

How do I get didReadData within GCDAsyncSocket execute within the current RunLoop?

I'm trying to get a simple example working with GCDAsyncSocket, and am discovering that I'm missing certain bits of understanding and hope you fine people can help explain this. I've setup the GCDAsyncSocket stuff below: dispatch_queue_t mainQueue =…
Sebastian Dwornik
  • 2,526
  • 2
  • 34
  • 57
6
votes
4 answers

Proper way to delay while allowing the run loop to continue

I have a need to delay for a certain amount of time and yet allow other things on the same runloop to keep running. I have been using the following code to do this: [[NSRunLoop currentRunLoop] runUntilDate:[NSDate…
Locksleyu
  • 5,192
  • 8
  • 52
  • 77
5
votes
2 answers

Is there a way to specify the run loop & mode to to receive elements from a publisher

I can specify the scheduler as RunLoop.main, but I could not find a native way to provide the associated RunLoop.Mode mode to receive elements from a publisher. Why do I need this: I'm updating a tableView cell from my publisher but the UI does not…
Ludovic Landry
  • 11,606
  • 10
  • 48
  • 80
5
votes
2 answers

How a runloop actually works

Earlier this month I asked this question 'What is a runloop?' After reading the answers and did some tries I got it to work, but still I do not understand it completely. If a runloop is just an loop that is associated with an thread and it don't…
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
5
votes
1 answer

How is it that Cocoa GUI Class Runs without invoking NSApplication or NSRunLoop

Why does the following code work ? It's a small Cocoa program that uses NSOpenPanel to select a file and open it in Emacs.app. It can be run from the command line with the starting directory as an argument. How does NSOpenPanel run without…
Colin
  • 2,089
  • 25
  • 34
5
votes
3 answers

Is it possible to check that main thread is idle / to drain a main run loop?

I've just read the following post and have tried to implement the approach described there: Writing iOS acceptance tests using Kiwi - Being Agile All the stuff described there does work perfectly. But! there is one thing that breaks determinism when…
Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129
5
votes
2 answers

How to create a Run Loop which is kicked only by performSelector... method calls?

I'm messing around with threads a little bit. Now consider this: I have a main thread. I start a new thread. In it's entry-point method, I want to make a run loop. Now the documentation tells meh that I have to have a input source. Otherwise my run…
user195531
  • 51
  • 1
  • 2
4
votes
1 answer

Stop an NSRunLoop from a timer

I've made a RunLoop with a timer that updates a label that displays a countdown. I need the RunLoop to stop once the countdown reaches zero, for the case where the the timer finishes normally I could just use runUntilDate, with the date being the…
Elbimio
  • 1,041
  • 2
  • 10
  • 25
4
votes
3 answers

runModalForWindow throttles http requests

I have url connection, which normally works fine NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:delegate]; But when I create a modal window, no…
Nikita Rybak
  • 67,365
  • 22
  • 157
  • 181
1
2 3
8 9