My program needs to load a new info into json in the background and load it into the database and I launch it like this
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ //загружаю json //запускаю запись в базу предварительно заблокировав NSManagedObjectContext });
everything goes fine, but when the user leaves this activity for the previous or any other, then viewWillDisappear is triggered and if the background has not finished yet, then the application hangs .. the question arises: how does the viewWillDisappear bang the background task in dispatch_async? Google did not give an answer (in android there is AsyncTask which can be canceled, but here I still do not understand.
Tell me a clue