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

NSStream (BLE L2CAP) on background thread

I'm looking for some verification of what i'm doing. Also, there's a lot of related topics here and there but none is complete / addresses all challenges. Overview / Requirements: BLE (L2CAP) Central able to talk to multiply simultaneously…
0
votes
1 answer

Table view scroll issue when there's a "modal loop code"

I've a problem with a UITableView scroll. In a view controller, I add my tableview and show it with presentModalViewController. The user has to select an item in the tableview before they can continue, and so the code must block waiting the…
Matteo
  • 39
  • 6
0
votes
0 answers

Something calls a method when the app is in the background

I am using a timer to check certain conditions every minute. Timer code:

 func startTimer() { timer?.invalidate() timer?.tolerance = 0.2 timer = Timer.init(fire: Day.dateWithNextMinute(), interval: 5, repeats: true) { [weak…
sergey_s
  • 113
  • 11
0
votes
3 answers

Synchronous Call to NSWindow makeKeyAndOrderFront

I am writing a small Cocoa application for Mac OS, and my goal is to show a window, and then read the pixels on the screen. I already know how to do the latter part, but am having trouble with having the window show up before proceeding. From what…
0
votes
1 answer

Multiple NSURLConnections in different classes running parallel

Currently I have UITableView and simple UIView in my iPad application. Each of them needs to get data from remote Web-service simultaneously. In each ViewController I create NSURLConnection and run a request to web service, but it seems that second…
WASD42
  • 2,352
  • 6
  • 27
  • 41
0
votes
0 answers

In what cases can there be such a situation when unit tests will run earlier than View is fully loaded?

I was stumbled upon RunLoop.current.run(until: Date()) string in ViewController unit testing tutorial. In article the author wrote: “ The RunLoop.current.run(until: Date()) statement makes sure the run loop associated with the current thread has…
Ninja
  • 309
  • 7
  • 26
0
votes
1 answer

Polling GCD main queue, to avoid deadlock

I have an iOS app, with multiple threads. In a background thread, I run some 3rd party code. The 3rd party code will occasionally call: dispatch_sync(dispatch_get_main_queue(), block); The callback has to be _sync, because it needs the answer and…
Kobski
  • 1,636
  • 15
  • 27
0
votes
1 answer

Objective C++, how to use runloop in background thread?

Big edit: I think the question can be simplified to--how can I run corebluetooth and initialize CBCentralManager in background thread? Thank you! I am making an an objective c++ application with CoreBluetooth that runs through the commandline, so…
0
votes
3 answers

Would I need to use the run loop with my NSTimer in this case?

I don't want to sleep() my app, but I do want it to wait while my timer completes it's action (basically updating 4 UILabels, one per second). There is some code that I want to fire back in the main loop, after the timer completes - I want it to…
Glib
  • 159
  • 1
  • 2
  • 7
0
votes
1 answer

HTTP server works in Cocoa application but not test case -- run loop issue?

I'm trying to add a GHUnit test case to this SimpleHTTPServer example. The example include a Cocoa application that works fine for me. But I can't duplicate the behavior in a test case. Here is the test class: #import #import…
jlstrecker
  • 4,953
  • 3
  • 46
  • 60
0
votes
1 answer

How to ensure that some code runs on same background thread with runloop

I am using realm in an iOS app. I am calling realm methods in a background thread. Realm objects can be used only in the thread where it was created. This means that I have to ensure that all the code related to accessing realm objects happen on the…
user10461683
0
votes
2 answers

Should I use NSOperation or NSRunLoop?

I am trying to monitor a stream of video output from a FireWire camera. I have created an Interface Builder interface with buttons and an NSImageView. While image monitoring is occurring within an endless loop, I want to: change some camera…
monty wood
  • 159
  • 1
  • 1
  • 9
0
votes
1 answer

Why Won't Asynchronous SOAP Web Services Calls Work

I used WSMakeStubs (in the dev tools) to generate stub code for accessing a SOAP web service. The calls I make to the object just block currently. When I try to use the async calls, nothing happens and I'm sure it has to do with my understanding of…
Matt Long
  • 24,438
  • 4
  • 73
  • 99
0
votes
1 answer

NSRunLoop timing issue

Maybe there is a better way, but I want to pop a choice list when a user taps a button in a UIalertView. I would like this list to pop while the alert view is still visible and have everything close when the user taps an item in the choice list. I…
user278859
  • 10,379
  • 12
  • 51
  • 74
0
votes
1 answer

NSRunLoop blocks incoming data

I try to use the Bluetooth communication synchronously. I send the data to the BTLE device and wait for the response to continue in the same method unless a timeout occurs. I wanted to use NSRUNLOOP for the wait. However, I have the problem that…
Henning
  • 421
  • 2
  • 11
  • 22