Questions tagged [ios-multithreading]

59 questions
0
votes
2 answers

Usage of NSLock in property setter

Let's say, there is a variable that I want to make thread safe. One of the most common ways to do this: var value: A { get { return queue.sync { self._value } } set { queue.sync { self._value = newValue } } } However, this property is not…
V.V.V
  • 235
  • 1
  • 13
0
votes
1 answer

iOS Swift: Initiate the download task for 100 URLs at a time (concurrent) in less than 20 seconds

In one of my project, we are working on one interesting feature, that is we have a rest json response, it contains 100 media download urls. Because of some security reasons, from response received time those URL's are valid for 20 seconds to start…
Anjaneyulu Battula
  • 1,910
  • 16
  • 33
0
votes
3 answers

Completion handler called twice (with threading)

I'm currently testing this code in the Xcode 10 playground (Swift 5): func one() { let test = "bla" two(test, completion: { (returned) in print(returned) }) } func two(_ test: String, completion: @escaping (_ returned:…
Neph
  • 1,823
  • 2
  • 31
  • 69
0
votes
0 answers

iOS OperationQueue: Concurrent asynchronous operations block screen

I'm quite new to multi-threading in iOS, and have some difficulties with the implementation of my task. I'd really appreciate any help from more experienced programmers. I have one URL address, as a starting point, to which I make a request, check…
0
votes
1 answer

Does synchronising a class property in setter - getter for thread safety impact performance?

I have a race condition in a class property. One thread is reading it on another is writing. Now i have come up with a solution to synchronise getter and setter of that property. The question is will this impact the performance of the application?…
0
votes
1 answer

Calling UIKit methods from other threads

I have a function that must be called from a non-main thread. In that thread, I am trying to determine status bar orientation like this: let currentInterfaceOrientation = UIApplication.shared.statusBarOrientation But I obviously get a run time…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
0
votes
1 answer

Proper thread handling

I've come to a problem where proper threading is needed, but I can't seem to optimise it correctly. Here's my method: -(void) method1 { // -1 to an NSInteger nsint1--; [self showActiviyIndicator:YES]; //act as loading screen [alloc…
JackyW
  • 345
  • 2
  • 11
0
votes
1 answer

swift, calling network another time in the same task's thread

Sorry for beginner's question. I have an action that depends on the result of the data returned from the network, and the action may require another network request. Since the first network request is called in datatask already, I want to use that…
EyeQ Tech
  • 7,198
  • 18
  • 72
  • 126
0
votes
2 answers

View Dependent on network Request

In order to fully render my View from my View Controller, I need to have a response from a network request. I have been trying to do this is many different ways, but have been unsuccessful each time. Originally, I had gotten it to work by making a…
luckybroman5
  • 284
  • 1
  • 8
0
votes
1 answer

Error - Thread 1: signal SIGABRT SpinCity

I am making an app for a project that displays a table of song titles and allows you to click on them to see more details about it. The name of the project is SpinCity. Below is the thread exception error: // main.m // SpinCity #import…
B. Steib
  • 1
  • 1
0
votes
1 answer

How to use presentViewController in a custom class?

I just update my code, but the alertWindow won't show up. I add break point in Xcode, it shows that the viewDelegate is nil. All delegates are nil. This is my code: class LoginViewController:UIViewController,AlertDelegate { override func…
beasone
  • 1,073
  • 1
  • 14
  • 32
0
votes
1 answer

NSCondtion with multiple threads

method1: - (void) method1 { [_condition lock]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ //Fetach data from remote, when finished call method2 [self…
0
votes
0 answers

Setting SQLITE_THREADSAFE in code/ Making Sqlite threadsafe

Sounds stupid but where should I set SQLITE_THREADSAFE in my code. Sqlite database in my app is used at multiple instances which I am accessing asynchronously. Thus, I want to make the database thread safe. One of the statement is as follows : -…
Nitish
  • 13,845
  • 28
  • 135
  • 263
-1
votes
1 answer

Using more Threads for reading the same file in Java

How can I read a file in Java using multithreading? It doesn't matter if it's slower than using once, I have to do it. So, for example, if there are 2 threads, the first reads the first line and, at the same time, the second reads the second line;…
Nicola Bernardi
  • 68
  • 1
  • 10
1 2 3
4