NSOperationQueue,NSOperation
我是 iPhone 新手。我在哪里获得 NSOperationQueue
、NSOperation
的示例?NSOperationQueue
、NSOperation
相对于线程有什么优势?
谢谢
I m new to iphone. where i get examples for NSOperationQueue
, NSOperation
?
What is the advantage of NSOperationQueue
, NSOperation
over thread?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
阅读文档。他们非常擅长解释和举例
http://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationObjects/OperationObjects.html%23//apple_ref/doc/ uid/TP40008091-CH101-SW1
NSOperation 比 NSThread 更容易管理。
Read the docs. They are really good at explaining and giving examples
http://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationObjects/OperationObjects.html%23//apple_ref/doc/uid/TP40008091-CH101-SW1
NSOperation is easier to manage than NSThread.
更高层次的抽象:也就是说,比
NSThreads
更容易编程,并且比NSThread
控制少一点。Higher level of abstraction: That is, easier to program than
NSThreads
and a little bit less control thanNSThread
.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 theNSOperation
class type.The
NSOperationQueue
handles and manages the execution of all theNSOperation
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, theNSInvocationOperation
class and theNSBlockOperation
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