cocoa design pattern

本文介绍了iOS开发中常用的几种设计模式,包括Abstract Factory、Adapter、Chain of Responsibility和Command等,并结合苹果官方文档解释了这些模式如何应用于实际项目中。

 object composition (Decorator pattern) is often a better technique than subclassing for extending class behavior.

1.Abstract Factory

provides an interface for creating families of related or dependent objects without specifying their concrete classes

提供接口创建相同或类似的对象,不需要指定其具体的类型

iso中主要体现在NSNumber和NSArray和NSString以及NSDcitionary上

https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW6

2.Adapter

The Adapter design pattern converts the interface of a class into another interface that clients expect

将一个类的接口准确转换成clinet期望的一个接口,主要使用协议

3.Chain of Responsibility

The Chain of Responsibility design pattern decouples the sender of a request from its receiver by giving more than one object a chance to handle the request.

责任链主要将请求的发送者和接收者解耦

ios中主要体现在响应者链上

An instance of the NSInvocation class encapsulates an Objective-C message

4.Command

The Command design pattern encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations

命令设计模式封装了对象的要求,从而让你的参数适应client不同的要求,排队或记录请求日志,支持撤消操作

ios上主要体现在NSInvocation上面

 

 

 

转载于:https://www.cnblogs.com/wustlj/archive/2012/08/16/2643157.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值