1
我想在后台线程中加载一些东西(大)(与NSOperation一起使用)。NSURLConnection在后台线程
许多搜索后,我遇到了两个选项: 首先是与使用:
CFRunLoopRun()
在这个环节讲解精彩: http://www.russellj.co.uk/blog/2011/07/09/nsurlconnection-in-a-background-thread/
二是与使用:
NSPort* port = [NSPort port];
NSRunLoop* rl = [NSRunLoop currentRunLoop]; // Get the runloop
rl addPort:port forMode:NSDefaultRunLoopMode];
这在这个链接里解释不错: http://www.cocoaintheshell.com/2011/04/nsurlconnection-synchronous-asynchronous/
我真的想用第一个选项,因为非常优雅和可读性。但恐怕我不太了解这两种方法之间的差异。
感谢您的帮助。