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
1
vote
1 answer

Can an open, but inactive, NSStream that is scheduled on the main thread be moved to a different thread?

I am using (and am required to use) a third-party framework to which I do not have source. The third-party framework handles creating an authenticated client/server connection and hands back a pair of open NSStreams. The challenge that I have is the…
xyzzycoder
  • 1,831
  • 13
  • 19
1
vote
3 answers

NSURLConnection needs a NSRunLoop to execute?

I'm trying to fetch the contents of a URL from a method called connect. It reads its configuration settings and attempts to fetch the URL. It appears to need the run loop to execute. I though it would just execute once and be done. It seems that…
Adam
  • 913
  • 1
  • 9
  • 26
1
vote
1 answer

Running an NSRunLoop with different dates changes observed thread count

While writing an app, I encountered some odd behavior that I wasn't expecting and distilled it down to the following: I made an app whose main function is as follows. While observing it in Activity Monitor, it uses one thread. int main(int argc,…
Halnry
  • 418
  • 2
  • 10
1
vote
1 answer

Using [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]] to let the scheduled selectors fire

In my application at some point I have a bunch of messages scheduled using performSelector. Under some conditions, while handling an UI action, I need to wait for all the currently scheduled selectors to fire. I could place my code in another method…
zrslv
  • 1,748
  • 1
  • 14
  • 25
1
vote
1 answer

How to add multiple timer to a thread

I'm trying to add multiple timers to a thread, not the main thread.Here is code: - (IBAction)addTimer:(id)sender { if (!_timerQueue) { _timerQueue = dispatch_queue_create("timer_queue", NULL); } dispatch_async(_timerQueue, ^{ NSTimer…
Tranz
  • 167
  • 1
  • 9
1
vote
2 answers

When I use NSRunLoop Instruments gave a leak

When I use the following code I was told there is a leak: - (void)dealloc { [connection release], connection = nil; [responseData release],responseData = nil; [cityCode release], cityCode = nil; [requestUrlString release],…
0
votes
1 answer

HttpConnection, UITableView and RunLoops and Loading from Disk

I'm loading images in to a large grid on a table view. They are coming from the net, but once downloaded they are cached to disk. I use this: [_httpConnection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; to ensure…
bandejapaisa
  • 26,576
  • 13
  • 94
  • 112
0
votes
1 answer

How to rewrite [NSRunLoop runUntilDate:] to GCD code?

Just for my curiousity, I am trying to rewrite the following code // show HUD (with animation) [SVProgressHUD showWithStatus:@"loading..."]; // wait for HUD to safely finish showing its animation // (loading HUD will be visible for 1…
inamiy
  • 2,896
  • 2
  • 17
  • 13
0
votes
2 answers

UIAlertView dismiss in a thread when main thread is blocked in IOS

I have an application which is waiting a connection. While the application is waiting i need to show AlertView to the user which should dismiss after sometime either programmatically or by the user clicking on cancel button of AlertView. The main…
Rajat
  • 314
  • 4
  • 15
0
votes
1 answer

iOS: If my app goes into the inactive state, what happens to pending delayed perform selector requests?

My hunch is that perform selectors that had been started with afterDelay values > 0.0 and that had remaining time on them when the app went into background will not execute in the background, but will resume with their clocks running down after the…
user945620
0
votes
1 answer

working with NSRunLoop

i'm running 2 methods in the viewDidLoad and between them im running NSRunLoop for 10 sec -(void)nextImage{ //charging a random image in the image view index = [[NSArray alloc]initWithObjects:@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg",@"5.jpg",nil]; …
Hamdi-Lachaal
  • 151
  • 1
  • 3
  • 8
0
votes
1 answer

How to stop NSRunLoop correctly?

I'm using NSRunLoop in my application. Just one statement [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2]]; performed in for loop. It is needed to update certain text each two seconds for three times. Everything…
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
0
votes
2 answers

How to adapt RunLoop to swift concurrency(async/await)

I'm having some compilation warnings using Xcode 14.2/swift 5.7 (future errors in swift 6). I've some async function tests in a unit test target which include some code to process UI changes in the main loop. There are two related…
kikeenrique
  • 2,589
  • 2
  • 25
  • 46
0
votes
1 answer

Loop the code in @implementation section

I have written the program, which chooses a random element from the array. Once I press the button "Start", how do I loop that code? I would like, that once a button "Start" is pressed, a new element from the array is chosen and written in the…
Damijan
  • 183
  • 1
  • 2
  • 7
0
votes
0 answers

A crash when APP running use CFRunLoopRun()

I recently encountered a difficult problem. My iOS APP uses runloop to implement resident threads, but creating and destroying resident threads multiple times will cause crashes. The crash log is as follows Exception Type: EXC_BAD_ACCESS…
pzh
  • 1