什么是“代表”在Objective C的iPhone开发中? [英] What is a "delegate" in Objective C's iPhone development?
本文介绍了什么是“代表”在Objective C的iPhone开发中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
看到这个讨论
委托允许一个对象在事件发生时将消息发送到另一个对象。例如,如果您使用 NSURLConnection类。 NSURLConnection有三个常见的代理:
- (void)connection:(NSURLConnection *)连接didFailWithError:(NSError *)错误
- (void)connectionDidFinishLoading:(NSURLConnection *)连接
- (void)连接:(NSURLConnection *)连接didReceiveResponse :( NSURLResponse *)响应
当NSURLConnection遇到失败,成功完成或从网站收到回复时,一个或多个这些代理将被调用。
What is a "delegate" in Objective C's iPhone development?
解决方案
See this discussion
A delegate allows one object to send messages to another object when an event happens. For example, if you're downloading data from a web site asynchronously using the NSURLConnection class. NSURLConnection has three common delegates:
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
One or more of these delegates will get called when NSURLConnection encounters a failure, finishes successfully, or received a response from the web site, respectively.
这篇关于什么是“代表”在Objective C的iPhone开发中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文