From what I can tell removeTask can be called by another task completion prior to the previous one being finished (if they finish at or near the same time) and therefore the NSUserDefaults isn't stored correctly and the task isn't removed from the NSUserDefaults - thus on subsequent launches it will try to complete a task already completed.
Am I doing something wrong or this indeed a race condition? I'm not sure what the best solution is to ensure that removeTask finishes before being called again to ensure the NSUserDefaults is removed correctly.
From what I can tell removeTask can be called by another task completion prior to the previous one being finished (if they finish at or near the same time) and therefore the NSUserDefaults isn't stored correctly and the task isn't removed from the NSUserDefaults - thus on subsequent launches it will try to complete a task already completed.
Am I doing something wrong or this indeed a race condition? I'm not sure what the best solution is to ensure that removeTask finishes before being called again to ensure the NSUserDefaults is removed correctly.