简体   繁体   中英

how to upload image in background in swift using GCD

i used the following code to upload image to server in background

var queue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
    dispatch_async((queue), {
        self.StartUploadProcess()//upload function
    })

the above code run perfectly in simulator but when i test the application on my iPad it will stop the background execution when user click home button or open other application

please help me so i can run the application even the user click on home button?

The point of dispatch_sync() is to run the code in another thread synchronously . There is also dispatch_async() which runs asynchronously , that is, in the background.

From your question I assume you already know how to run it when you want to, just need to make it into an async call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM