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
4
votes
2 answers

How to test if a UIControlEvents has been fired

I have a library implementing a custom UIControl with a method which would fire a .valueChanged event when called. I would like to test the method for that behavior. My custom control: class MyControl: UIControl { func fire() { …
Thanh Pham
  • 2,021
  • 21
  • 30
4
votes
2 answers

How to remove timer from runloop immediately

I have a timer triggered in 5 seconds added to global queue, though i am invalidating it after 2 seconds run loop won't terminate till 5 seconds. In the following snippet backgroundTimer is an instance var, and run is a member function. What's wrong…
pradeepa
  • 4,104
  • 5
  • 31
  • 41
4
votes
1 answer

difference between Runloop and thread?

What is run loops actually ? what a difference from thread ? Where we must need to use run loop and where aren't we use ?
virus
  • 1,203
  • 13
  • 21
4
votes
1 answer

How does runLoop in GCD block work without source

I was trying to understand multithreaded programming in iOS. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) , ^{ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL …
4
votes
1 answer

Is performSelector:onThread:withObject:waitUntilDone: ordered?

I have an Objective-C class which spins up a background thread and runs an NSRunLoop on it. I would like to deliver messages to the background thread from the main thread (yes, exclusively from the main thread). To do this, I am planning to use the…
Alex Nichol
  • 7,512
  • 4
  • 32
  • 30
4
votes
4 answers

How can I exit [NSRunLoop runUntilDate]?

I am writing an application which has to communicate with a device connected via USB. The app sends and receives data in turns from the device on a fixed timing. All Rx/Tx happens in a separate thread because otherwise the UI would be blocked. The…
insanelygreat
  • 53
  • 1
  • 4
4
votes
2 answers

how to use NSRunLoop in objective-C?

how to use how to use NSRunLoop in objective-C and wait for some variable to change value ? Thanks
Biranchi
  • 16,120
  • 23
  • 124
  • 161
4
votes
2 answers

NSRunLoop- Clarification needed

I am trying to understand the concept of RunLoops. I have read Apple developer's guide on RunLoops and to some extent I have understood the concept of RunLoops. To make my concept more clearer I wrote a very simple code which uses RunLoops in it.…
tek3
  • 2,095
  • 2
  • 20
  • 50
4
votes
1 answer

NSRunLoop API difference

NSRunLoop has two apis: - (BOOL)runMode:(NSString *)mode beforeDate:(NSDate *)limitDate and - (void)acceptInputForMode:(NSString *)mode beforeDate:(NSDate *)limitDate I mean they are same except return value, or there are other differences?
Richard
  • 339
  • 3
  • 10
4
votes
1 answer

Scheduling NSStream events on an NSRunLoop that isn't the main run loop

I'm scheduling events on the main run loop using the following code: [stream setDelegate:self]; [stream scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [stream open]; I assume that this means that NSStreamDelegate events…
chris838
  • 5,148
  • 6
  • 23
  • 27
4
votes
1 answer

How to manage the autorelease pool of a NSRunLoop running in a secondary thread?

In Apple's MVCNetworking sample code, the NetworkManager class includes this method to maintain a run loop in a secondary thread dedicated to network activity (in order to run NSURLConnection asynchronously): - (void)networkRunLoopThreadEntry { …
Guillaume
  • 4,331
  • 2
  • 28
  • 31
4
votes
1 answer

Main Thread Runloop gets blocked on opening nsmenu

I have an application for which the UI element includes an NSStatusItem and a menu. Inside my application , I am using NSTask asynchronously to perform some operation and I am using the output obtained using the …
3
votes
1 answer

HID Report callback on a different runLoop

I've scheduled HIDManager on main thread (runLoop) using IOHIDManagerScheduleWithRunLoop. So, I get the device matching & removal callbacks on main thread. But, I've scheduled a device IOHIDDeviceScheduleWithRunLoop on a different thread, Say…
coder000001
  • 476
  • 4
  • 22
3
votes
3 answers

iOS dispatch_async and NSURLConnection delegate functions not being called

I've edited this post to make it simpler to read, I think. I need to call an NSUrlConnection after I've finished doing some intensive string manipulation in a dispatch_async block. The URL I call has got .htaccess authentication on it, so I can't…
Pete
  • 4,542
  • 9
  • 43
  • 76
3
votes
1 answer

Cocoa's Event Driven System: where do background tasks run?

On Mac OS X, Cocoa is event driven. By this I mean each thing is driven by the UI - the user clicking something or moving over a certain area results in an event handler being called. Main simply calls NSApplicationMain () which creates an infinite…
fdh
  • 5,256
  • 13
  • 58
  • 101