Delegate
来源:互联网 发布:王国保卫战2 mac 编辑:程序博客网 时间:2024/04/29 19:21
dele gate (delegator gives tasks to another delegate objects to handle)
The delegation pattern is a design pattern whereby an object (the delegator) delegates one or more tasks to another delegate object. The tasks are encapsulated in the method(s) of the delegate object. When necessary, the delegator invokes the appropriate method on the delegate object, providing any required parameters.
Delegator,Delegating Object;
v.s.
Delegate Object
Examples:
The delegation pattern is a design pattern whereby an object (the delegator) delegates one or more tasks to another delegate object. The tasks are encapsulated in the method(s) of the delegate object. When necessary, the delegator invokes the appropriate method on the delegate object, providing any required parameters. Many Foundation Framework classes implement the delegation pattern to enable custom error handling. The delegating Foundation object invokes a method on a delegate object (custom code that you implement) that includes an error object as a parameter.
The NSURLConnectionDelegate protocol declares a delegation method (connection:didFailWithError:) that returns an error object:
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
This protocol is used for asynchronously loading a URL request via an NSURLConnection object. Your code implements a delegate object that conforms to this protocol and sets it as the delegate of theNSURLConnection object. Your code then loads the URL request asynchronously, and if an error occurs, the delegating (NSURLConnection) object invokes the connection:didFailWithError:method on your delegate object.
- delegate
- delegate
- Delegate
- delegate
- Delegate
- Delegate
- Delegate
- Delegate
- delegate
- Delegate
- Delegate
- Delegate
- Delegate
- delegate
- Delegate
- delegate
- delegate
- delegate
- Linux鸟哥私房菜学习笔记_第八章Linux磁盘与文件系统管理
- struts2 jsp页面提交时,命名空间重复出现
- 致IT同仁 —— IT人士常犯的17个职场错误
- Linux鸟哥私房菜学习笔记_第九章档案与文件系统的压缩与打包
- hdu 1565 方格取数(1) (最小割/状态压缩+DP)
- Delegate
- 2013-C++第13周项目参考解答链接集
- asp.net调用sql server存储过程的实例
- python __init__.py
- Dom4j解析XML学习之利用解析的数据进行JDBC操作
- [数据结构与算法]第一周(二):线性表---位查询&&放苹果
- Dom4j 解析Atom 文档
- hbase+eclipse 常见问题解决方案
- Linux鸟哥私房菜学习笔记_第十章vim程序编辑器