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

NSRunLoop cancelPerformSelectorsWithTarget's not working

I have this following code and I am not getting the results I expected. #import "CancelPerformSelectorTestAppDelegate.h" @implementation CancelPerformSelectorTestAppDelegate @synthesize window; - (BOOL)application:(UIApplication *)application…
Nick
  • 2,662
  • 2
  • 25
  • 48
0
votes
1 answer

get NSRunLoop instance

I have a class which inherits NSThread: @interface MyService : NSThread { ... } In another class, I get a instance of MySerivce: MyService *service = [self getServiceInstance]; // here, how can I get the NSRunLoop instance out from service ? I…
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
0
votes
1 answer

Use NSOutputstream and NSInputstream to write and read every interval

I'm trying to use NSOutputstream and NSInputstream to write and read every interval, say 5 seconds. This is to communicate with a C# program on windows in P2P fashion. I want to use NSOutputstream to send the C# program a request every 5 seconds and…
Bon
  • 3,073
  • 5
  • 21
  • 40
0
votes
2 answers

cancelPreviousPerformRequests with arbitrary object

I am scheduling a method to be called with an object in the near future and the object is just a random NSString that is gone as soon as I schedule the selector. So I may say something like: [self performSelector:@selector(runMethod:)…
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
0
votes
1 answer

NSTimer Logic Failing Somewhere

I've been able to reproduce a defect in our app twice, but most times I fail. So I'm trying to understand what could possibly be going on here and hopefully have some new things to try. Our app times out and logs the user out after 10 minutes using…
Bill L
  • 2,576
  • 4
  • 28
  • 55
0
votes
1 answer

Looping a CFRunLoopSource

Here is the source files I'm currently developing. The idea behind this class is to contain a target object and selector which will be invoked in whatever CFRunLoop passed to scheduleInCFRunLoop. I need this to loop repeatedly without consuming all…
drreed
  • 1
  • 1
0
votes
1 answer

Why is my application terminating in the middle of unit tests?

The Problem I run my unit tests. At one point, I wait using: [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]]; for an NSOperationQueue to be empty. When my app reaches this line, it terminates immediately. It's run…
John Gallagher
  • 6,208
  • 6
  • 40
  • 75
0
votes
1 answer

Show an alert and wait for button press

I'm trying to implement a method alertAndWait that should work when called from main thread "directly" and when dispatched like this: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ …
0
votes
2 answers

Execute a method infinitely using NSTimer and NSRunLoop

I need to execute one method at a intervals of 1min for every 30min. After 30mins, i want to sleep app for next 30mins. I tried with UIBackgroundTaskIdentifier API, it allow me to execute code only for 180sec not more than that. I dont want to use…
sanjayzed
  • 57
  • 9
0
votes
1 answer

Cannot stop NSRunLoop in a console app

For a project I need to use CoreLocation services but from another language. However, the problem is an infinite NSRunLoop. I tried to use observers but without any success. I don't get anything in - (void)locationManager:(CLLocationManager…
Andrei Nechaev
  • 225
  • 3
  • 12
0
votes
1 answer

scheduling async downloads in main thread's runloop vs bg thread's runloop on iOS?

Here's a slide from WWDC 2010 session 208: conn = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:NO]; [conn scheduleInRunLoop: [NSRunLoop currentRunLoop] forMode: NSDefaultRunLoopMode]; [conn start]; Are there any…
Henry
  • 32,689
  • 19
  • 120
  • 221
0
votes
1 answer

What's the purpose of CFRunLoopScheduleCallBack function in CFRunLoopSource?

I'm trying to define custom input source for CFRunLoop, I've read the Threading Programming Guide document wrote by Apple and this problem is the only one that I cannot understand. So, I want to know what is the purpose of CFRunLoopScheduleCallBack…
Sherlock
  • 13
  • 4
0
votes
1 answer

Error at NSRunLoop after returning from thread method with NSAutoreleasePool

I am getting an EXC_BAD_ACCESS error after I return from a thread method in which I have set up an NSAutoreleasePool. The place of failure is at a call to NSRunLoop. I am trying to wrap a 3rd party library consisting mainly of a class (let's call…
Rich Everhart
  • 1,043
  • 4
  • 19
  • 29
0
votes
2 answers

NSURLConnectionDelegate methods not called when on background thread

I am using MoPub for ad mediation in my iOS app. I received a couple of user complaints about blocked UI when an ad is loading. I could replicate this only under certain low-quality network conditions. My naive assumption was that all I had to do…
thomers
  • 2,603
  • 4
  • 29
  • 50
0
votes
1 answer

Clear process flow of NSRunLoop

Digging more than one day....Apple, Google, Slideshare and stackoverflow. But still not clear about NSRunLoop. Every thread has a runloop by default.Application mainThread has mainRunLoop. 1. If MainRunLoop get input events is it creating new…
Sofeda
  • 1,361
  • 1
  • 13
  • 23