0

I have a crash that seems to happen on the remove function in Swift 1.2's Set. I'm guessing it isn't thread safe. How can I make it thread safe or is there an alternative that is thread safe? Thanks!

EDIT: It is defined as a static var in a struct.

Here is the code:

struct Syncer {
    static var isSyncing = Set<HKQuantityType>()
}

Syncer.isSyncing.remove(quantityType)
jestro
  • 2,524
  • 4
  • 27
  • 46

1 Answers1

1

It is not thread safe. You can try to always access/update if from the same thread. Or protect it with locks, semaphores, etc.

Joe Smith
  • 1,900
  • 1
  • 16
  • 15