grand-central-dispatch Questions

2

Solved

I've been experimenting with GCD priorities recently. Here's the snippet of code that I've been working with. for _ in 1...1000 { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_...
Speckle asked 30/8, 2016 at 18:51

2

Solved

I noticed that my app doesn't request permission to use the camera. After some experimentation I figured out that the piece of code used to check permission takes a very long time to complete. So I...
Impatience asked 29/1, 2015 at 12:0

6

Solved

The answers I've seen so far (1, 2, 3) recommend using GCD's dispatch_once thus: var token: dispatch_once_t = 0 func test() { dispatch_once(&token) { print("This is printed only on the first...
Malkamalkah asked 10/12, 2015 at 13:51

5

Solved

From what I've read about Grand Central Dispatch, GCD does not do preemptive multitasking; it is all a single event loop. I'm having trouble making sense of this output. I have two queues just doin...
Selfheal asked 15/12, 2011 at 19:56

4

Solved

I am hitting a web service url 10 times and getting the response. I am using Alamofire and SwiftyJSON. This is my controller code class ViewController: UIViewController { let dispatchGroup = Dis...

4

Solved

I want to display an ActivityIndicatorView in my app, but when I call the sync method from the main thread, the app crashes with the error: exc_bad_instruction (code=exc_i386_invop subcode=0x0) I'm...
Corissa asked 20/10, 2016 at 12:35

2

Solved

I have converted existing Swift2.3 code to Swift3.0 using Xcode8 beta4. Xcode automatically convert syntax to Swift3.0, but it not able to create serial dispatch queue. private let serialQueue = D...
Pellikka asked 6/9, 2016 at 9:5

1

Solved

In GCD I just call: DispatchQueue.main.asyncAfter(deadline: .now() + someTimeInterval) { ... } But we started to migrate to Structured Concurrency. I tried the following code: extension Task where...

12

Solved

I have a method which should support being called from any queue, and should expect to. It runs some code in a background thread itself, and then uses dispatch_get_main_queue when it returns a val...

2

I have a series of HTTP requests made sequentially using Alamofire in a list of functions called in a main function, runTask() that I want to have the ability to stop. So, I set up the runTask() fu...

4

Solved

All the libraries I have come across that provide Swift concurrency functionality either depend on an Objective-C library or are wrappers around the C based GCD. (iOS and OS X) I'm just wondering ...
Paperboy asked 3/3, 2016 at 11:42

7

Solved

For the longest time I thought asynchronous was synonymous to running something on a background thread, while synchronous meant on the main thread (blocking UI updates and interactions). I understa...

4

I want to run a block of code only once per instance. Can I declare dispatch_once_t predicate as a member variable instead of static variable? From GCD Reference, it is not clear to me. The p...
Bangup asked 13/12, 2012 at 8:45

3

Solved

I am currently playing around with Grand Central Dispatch and discovered a class called DispatchWorkItem. The documentation seems a little incomplete so I am not sure about using it the right way. ...

4

Solved

First I create a serial queue like this static dispatch_queue_t queue = dispatch_queue_create("myQueue", DISPATCH_QUEUE_SERIAL); then, at some unknown point in time a task gets added to the queu...
Selfmade asked 7/9, 2012 at 11:24

3

Solved

I am trying to implement a Thread-Safe PhoneBook object. The phone book should be able to add a person, and look up a person based on their name and phoneNumber. From an implementation perspective ...

2

Solved

I am facing an issue in using semaphores on iOS. I am implementing a feature to execute a series of async methods sequentially, one after another in order. let semaphore = DispatchSemaphore(value: ...
Intermit asked 29/8, 2022 at 17:11

1

I am trying to implement dispath group , to perform a sequence of operations , that should execute one after another. But the issue is all the tasks adding to the group are executing in parallel. P...
Repertory asked 9/8, 2022 at 14:17

10

If I have a serial queue, how can I, from the main thread, tell it to immediately stop execution and cancel all of its tasks?

9

Solved

In Apple docs, it says: Important: You should never call the dispatch_sync or dispatch_sync_f function from a task that is executing in the same queue that you are planning to pass to the fun...
Stuckey asked 13/3, 2013 at 9:21

11

Solved

In my app I have a function that makes an NSRURLSession and sends out an NSURLRequest using sesh.dataTaskWithRequest(req, completionHandler: {(data, response, error) In the completion block for ...
Attribution asked 27/7, 2014 at 21:12

7

Solved

I'm moving my code from regular GCD to NSOperationQueue because I need some of the functionality. A lot of my code relies on dispatch_after in order to work properly. Is there a way to do something...

4

Ok so I have gone through a ton of questions and answers and I know the understanding of it, but when I am trying some code, I am getting some results that doesnt stand by those theories. What I ...
Spiegel asked 8/6, 2017 at 7:24

3

Solved

I have a ViewController that has a collectionView inside of it. I display the contents of the collectionView's cells inside an ARSCNView. When I set the ViewController's view property to the Mater...
Ganef asked 22/12, 2019 at 17:13

2

I had an error when sending data to a firebase database : Access to fetch at 'https://us-central1-pwagram-f39a5.cloudfunctions.net/storePostData' from origin 'http://localhost:3030' has been blo...
Moffitt asked 18/1, 2020 at 9:37

© 2022 - 2024 — McMap. All rights reserved.