Questions tagged [nsrunloop]

NSRunLoop is a class in Apple's Foundation framework. It processes inputs such as user events, network activity, and NSTimer events.

NSRunLoop is a class in Apple's Foundation framework for OS X and iOS. It processes inputs such as user events, network activity, and NSTimer events. Each NSThread object automatically receives its own NSRunLoop; apps cannot explicitly create or manage NSRunLoop objects.

353 questions
7
votes
2 answers

Objective-C: How does code in main thread and its runloop interact?

How does code in main thread and its runloop interact? For example, does all code in main thread have to run until it is idle before hitting the runloop? Or does runloop check its sources in the middle of executing the code in main thread? Is it…
Boon
  • 40,656
  • 60
  • 209
  • 315
7
votes
1 answer

What happens to my NSRunLoop and timer when the app goes into background and returns?

I have an NSRunLoop in my app connected to a timer: NSTimer *updateTimer = [NSTimer scheduledTimerWithTimeInterval:300 target:self selector:@selector(onUpdateTimer) userInfo:nil repeats:YES]; [[NSRunLoop mainRunLoop] addTimer:updateTimer…
dgund
  • 3,459
  • 4
  • 39
  • 64
6
votes
2 answers

Using NSThread sleep in an NSOperation

Working with some code, I'm coming across run loops, which I'm new to, inside NSOperations. The NSOperations are busy downloading data - and whilst they are busy, there is code to wait for the downloads to complete, in the form of NSRunLoops and…
bandejapaisa
  • 26,576
  • 13
  • 94
  • 112
6
votes
3 answers

Multiple locks on web thread not allowed! Please file a bug. Crashing now

i make a url-Request and waiting for the answer with I start the request, then waiting until synchronousOperationComplete=TRUE NSRunLoop *theRL = [NSRunLoop currentRunLoop]; while (!synchronousOperationComplete && [theRL…
Starbax
  • 1,005
  • 2
  • 12
  • 32
6
votes
2 answers

What is an NSTimer's behavior when the app is backgrounded?

I know that when you background an app, the timer stops running. However, what is the behavior when you come back from the background? Does the timer maintain its original fireDate? I've run into a bit of an issue where upon returning from the…
Bill L
  • 2,576
  • 4
  • 28
  • 55
6
votes
4 answers

How to wrap an asynchronous class to make it synchronous? Use NSRunLoop?

I'm currently working on an iPhone app and I have a library from a third-party that has asynchronous behavior but that I'd like to wrap with my own class and make it appear synchronous. The central class in this library, let's call it the…
Rich Everhart
  • 1,043
  • 4
  • 19
  • 29
6
votes
2 answers

How to deal with concurrency issues brought by NSStream run loop scheduling using GCD?

I have the following situation where I create a GCD dispatch queue and in it I schedule an NSStream to the current NSRunLoop, as is required in its specification for it to emit delegate events, and then I make the run loop for that thread run using…
Matoe
  • 2,742
  • 6
  • 33
  • 52
6
votes
2 answers

What does NSRunLoop do?

I read many posts about NSRunLoop, like this, this, this. But can't figure out what NSRunLoop actually does What I usually see is a worker thread wthread = [[NSThread alloc] initWithTarget:self selector:@selector(threadProc) object:nil]; [wthread…
onmyway133
  • 45,645
  • 31
  • 257
  • 263
6
votes
1 answer

NSTimer and NSRunLoop

My app tracks a user with CLLocationManager. In the delegate call didUpdateToLocation I do all the fun stuff of saving their position. However, I needed a way to test if they had stopped. That away I could stop recording locations and consider their…
random
  • 8,568
  • 12
  • 50
  • 85
6
votes
4 answers

NSURLConnection with NSRunLoopCommonModes

I have written my own implementation of HTTPClient for my iOS app to download contents of specified URL asynchronously. The HTTPClient uses NSOperationQueue to enqueue the NSURLConnection requests. I chose NSOperationQueue because I wanted to cancel…
indiantroy
  • 1,503
  • 1
  • 15
  • 25
5
votes
2 answers

NSRunloop runUntilDate causes application crash

I have an application which runs for days and weeks on a Snow Leopard server. It uses -[NSRunLoop runUntilDate:] to "pause" for ten seconds, perform its task and then pause again. After running for over one hour, my app crashes with the following…
helioz
  • 910
  • 11
  • 22
5
votes
1 answer

AVPlayerStatus vs AVPlayerItemStatus

The issue is that player.status returns AVPlayerStatusReadyToPlay a full 2 seconds before player.currentItem.status returns AVPlayerItemStatusReadyToPlay. Does anyone have any helpful explanations as to why this is happening? This is just sample…
SteveB
  • 652
  • 3
  • 12
5
votes
1 answer

Using AsyncSocket with secondary threads on the iPhone

I use AsyncSocket on the iPhone to communicate with a server. AsyncSocket is based on run loops but my app is based on threads. That means, I start a new thread to write data and wait until a response is received on the same thread. But I can't call…
Arthur
  • 151
  • 1
  • 1
  • 6
5
votes
0 answers

Attach custom input source to a run loop in Swift

Does anyone know a way to attach custom input source to a run loop with Swift language ? I am following this documentation : Run Loops in particular: "Configuring Run Loop Sources", but I have not figured out how to use it with swift.
emacos
  • 541
  • 1
  • 8
  • 17
5
votes
1 answer

Strictly scheduled loop timing in Swift

What is the best way to schedule a repeated task with very strict timing (accurate and reliable enough for musical sequencing)? From the Apple docs, it is clear that NSTimer is not reliable in this sense (i.e., "A timer is not a real-time…
c_booth
  • 2,185
  • 1
  • 13
  • 22
1 2
3
23 24