开发者

How does Objective-C's asynchronous request model work?

开发者 https://www.devze.com 2023-01-24 18:34 出处:网络
I\'ve been playing with Objective-C the past couple of weeks and have a working app that performs an async HTTP Request to pull some data from Twitter.

I've been playing with Objective-C the past couple of weeks and have a working app that performs an async HTTP Request to pull some data from Twitter.

I come from a web application background and have become use to how Javascript handles callbacks by passing a function that is called when an XHR request is开发者_如何学编程 done loading. As such, I find Objective-C's model of handling async requests with delegate objects and the perfomSelector method pretty darn cool.

[callbackObj performSelector:@selector(callbackMethod:) withObject:argObj];

So my question is, what is the design of Objective-C's async model and how does it work?


All of "Cocoa Classic's" async behavior is / was implemented on top of NSRunLoop. Many of the more recent additions and updates to Cocoa are moving to Grand Central Dispatch.

0

精彩评论

暂无评论...
验证码 换一张
取 消