Last In-First Out Stack with GCD?

前端 未结 8 1406
予麋鹿
予麋鹿 2020-11-28 22:01

I have a UITableView that displays images associated with contacts in each row. In some cases these images are read on first display from the address book contact image, and

相关标签:
8条回答
  • 2020-11-28 22:41

    I do something like this, but iPad-only, and it seemed fast enough. NSOperationQueue (or raw GCD) seems like the simplest approach, in that everything can be self-contained and you don't need to worry about synchronization. Also, you might be able to save the last operation, and use setQueuePriority: to lower it. Then the most recent one will be pulled from the queue first. Or go through all -operations in the queue and lower their priority. (You could probably do this after completing each one, I assume this would still be significantly faster than doing the work itself.)

    0 讨论(0)
  • 2020-11-28 22:41

    I'm a big fan of NSOperationQueue's interface and ease-of-use, but I also needed a LIFO version. I ended up implementing a LIFO version of NSOperationQueue here that has held up quite well for me. It mimics NSOperationQueue's interface, but executes things in a (roughly) LIFO order.

    0 讨论(0)
提交回复
热议问题