?? iOS Dev Tip #1

?? Can you spot the bug?

Check out this snippet and challenge your iOS knowledge:

Q: What’s wrong with the code below, and how would you improve it?

A: The above code introduces a?race condition?issue which can always happen if multiple threads access a shared resource. To fix it we can have a computed property?array that uses an?internalQueue?to access the "real"?_array?property. Also, to have better performance?internalQueue?is created as concurrent. A?barrier?flag is used to ensure that the work will be executed when all previously scheduled work on the queue has finished.


要查看或添加评论,请登录

社区洞察

其他会员也浏览了