NSOperationQueue,NSOperation

发布于 2024-10-20 00:27:44 字数 168 浏览 3 评论 0原文

我是 iPhone 新手。我在哪里获得 NSOperationQueueNSOperation 的示例?
NSOperationQueueNSOperation 相对于线程有什么优势?

谢谢

I m new to iphone. where i get examples for NSOperationQueue, NSOperation?
What is the advantage of NSOperationQueue, NSOperation over thread?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

素罗衫 2024-10-27 00:27:44

更高层次的抽象:也就是说,比 NSThreads 更容易编程,并且比 NSThread 控制少一点。

Higher level of abstraction: That is, easier to program than NSThreads and a little bit less control than NSThread.

卷耳 2024-10-27 00:27:44

NSOperationQueue

NSOperationQueue 对象是处理 NSOperation 类类型的对象的队列。
NSOperationQueue 处理并管理已添加到其中的所有 NSOperation 对象(任务)的执行。执行是在应用程序的主线程中进行的。当 NSOperation 对象被添加到队列中时,它会立即执行,并且在完成之前不会离开队列。可以取消任务,但在完成之前不会将其从队列中删除。

NSOperation

NSOperation 旨在处理或多或少的批处理操作。
简而言之,一个 NSOperation 对象代表一个任务,包括与该任务相关的数据和代码。
NSOperation 类是一个抽象类,因此不能直接在程序中使用。相反,提供了两个子类:NSInitationOperation 类和NSBlockOperation 类。

当然,了解更多详细信息 Apple iOS Developer Library 是最好的选择,下面的链接也将有助于了解更多关于它和 NSOperationQueue、NSOperation VS 线程的信息。

NSThread 与 NSOperationQueue 与 ???在 iPhone 上

http://www.raywenderlich .com/19788/how-to-use-nsoperations-and-nsoperationqueues

NSOperationQueue:

An NSOperationQueue object is a queue that handles objects of the NSOperation class type.
The NSOperationQueue handles and manages the execution of all the NSOperation objects (the tasks) that have been added to it. The execution takes place with the main thread of the application. When an NSOperation object is added to the queue it is executed immediately and it does not leave the queue until it is finished. A task can be cancelled, but it is not removed from the queue until it is finished.

NSOperation:

NSOperation is designed to handle more-or-less batch operations.
An NSOperation object, simply phrased,represents a single task, including both the data and the code related to the task.
The NSOperation class is an abstract one so it cannot be used directly in the program. Instead, there are two provided subclasses, the NSInvocationOperation class and the NSBlockOperation class.

OfCourse for more details Apple iOS Developer Library is the best option and the link below would also help to know more about it and NSOperationQueue, NSOperation VS thread.

NSThread vs. NSOperationQueue vs. ??? on the iPhone

http://www.raywenderlich.com/19788/how-to-use-nsoperations-and-nsoperationqueues

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文