I have written a code to execute in background as follows
DispatchQueue.global(qos: .background).async {
for index in 1...50 {
print("\(index)")
usleep(1000000)
}
DispatchQueue.main.async {
print("done")
}
}
but when i press home and app goes to background code execution stops
How to to keep it running even when app goes in background