I need to pause a running NSOperation which was inserted in an NSOperationQueue. Currently I am canceling all operations and restarting them. But this would lead to some kind of duplication in terms of process done. I tried with setSuspended flag of NSOperationQueue. But it's not suspending the operation. Is there any way out?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
see this: Link
And here from the apple docs:
I've not tried this, but I would probably start here:
isPaused
flag to yourNSOperation
subclasssetCancelled:
(watch for this change in-main
)-main
if in-main
note that this will just suspend it. if you really want to pause and explicitly resume, you would manually 'new operation` when you want to resume.
now, if you are observing or have special completions, then you will have a few other problems. for simple cases, it seems this approach would seem to work fine.