Objective-C中设计模式总结
来源:互联网 发布:进口零食推荐知乎 编辑:程序博客网 时间:2024/06/09 20:01
本篇文章将Gang of Four中所列举的设计模式在Objective-C中的使用从名称,定义,何时使用,UML图以及在Cocoa Touch中的应用五个维度做出了总结。具体的列表请看下图。因为本人水平有限,所以有错误或者不正确的地方欢迎提出意见和建议。
Specify the kinds of objects to create using a prototypical instance,and create new objects by copying this prototype.
Define an interface for creating an object, but letsubclasses decide which class to instantiate. Factory Method lets a class defer instantiation tosubclasses.
Provides an interface for creating families of related or dependent objectswithout specifying their concrete classes.
Ensures a class has only one instance, and provide a global point ofaccess to it.
UIApplication,UIAccelerometer, andNSFileManager.
Decouples an abstraction from its implementation so that the two canvary independently.
Provides a unified interface to a set of interfaces in a system. Façadedefines a higher-level interface that makes the subsystem easier to use.
Defines an object that encapsulates how a set of objects interacts.Mediator promotes loose coupling by keeping objects from referring to each other explicitly, andit lets you vary their interaction independently.
Defines a one-to-many dependency between objects so that whenone object changes state, all its dependents are notified and updated automatically.
Compose objects into tree structures to represent part-wholehierarchies. Composite lets clients treat individual objects and compositions of objectsuniformly.
Provide a way to access to the elements of an aggregate object sequentially withoutexposing its underlying representation.
The Visitor pattern represents an operation to be performed on the elements of an objectstructure. Visitor lets you define a new operation without changing the classes of the elements onwhich it operates.
Attaches additional responsibilities to an object dynamically.Decorators provide a flexible alternative to subclassing for extending functionality.
To avoid coupling the sender of a request to its receiverby giving more than one object a chance to handle the request. It chains the receiving objectsand passes the request along the chain until an object handles it.
Define the skeleton of an algorithm in an operation,deferring some steps to subclasses. Template Method lets subclasses redefine certain steps ofan algorithm without changing the algorithm's structure.
rotatingHeaderView
rotatingFooterViewwillAnimateRotationToInterfaceOrientation:duration:willRotateToInterfaceOrientation:duration:
Define a family of algorithms, encapsulate each one, and makethem interchangeable. Strategy lets the algorithm vary independently from clients that use it.
Encapsulate a request as an object, thereby letting you parameterizeclients with different requests, queue or log requests, and support undoable operations.
NSInvocation,NSUndoManager, and the target-action
Uses sharing to support large numbers of fine-grained objectsefficiently.
Provides a surrogate or placeholder for another object to control accessto it.
Without violating encapsulation, capture and externalize an object’sinternal state so that the object can be restored to this state later.
The Cocoa Touch framework has adopted the Memento pattern with archiving, propertylist serialization, and core data.
- Objective-C中设计模式总结
- Objective-c:设计模式
- Objective-C的几种常用设计模式的总结
- objective c设计模式--KVO
- objective c设计模式--KVC
- 【Objective-C】OC中代理(委托)设计模式
- objective c 中MVC模式
- Objective-C 设计模式之单例
- Objective-c中的单例设计模式
- Objective-c中的键值观察设计模式
- 设计模式,objective-c单例
- Objective-c ;单例设计模式
- 【Objective-C】OC中单例设计模式讲解
- Objective-C自学之常用设计模式
- Objective-c 单例设计模式
- objective c单例设计模式
- objective c设计模式--通知中心
- Objective-c 单例设计模式
- 第三章:UVa227 解题报告
- poj 杂题 - 1083 Moving Tables
- mixin
- 特殊数据类型成员变量的初始化(转)
- Shell基础-Bash变量-环境变量(上)
- Objective-C中设计模式总结
- HDU--1698(线段树,区间修改成段替换)
- c# 窗口应用程序开发过程中碰到的一些问题。
- 按位与、或、异或等运算方法
- PLSQL Developer V9 注册码
- new一个类对象和使用类名创建一个对象有什么区别?该怎么解决
- 【OpenCV】基本数据类型、IplImage数据结构
- 取消按钮的高亮状态
- 两天的学习成果整理。。。之后还会添加并整理