├── .gitignore ├── 设计图 ├── 中介者模式.png ├── 享元模式.png ├── 代理模式.png ├── 单列模式.png ├── 原型模式.png ├── 命令模式.png ├── 备忘录模式.png ├── 外观模式.png ├── 工厂方法模式.png ├── 建造者模式.png ├── 抽象工厂模式.png ├── 桥接模式.png ├── 模板方法模式.png ├── 状态模式.png ├── 策略模式.png ├── 简单工厂模式.png ├── 组合模式.png ├── 装饰模式.jpg ├── 观察者模式.png ├── 解释器模式.png ├── 访问者模式.png ├── 责任链模式.png ├── 迭代器模式.png └── 适配器模式.png ├── 2策略模式 ├── .DS_Store ├── 2策略模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ ├── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── yifan.xcuserdatad │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 2策略模式 │ ├── ViewController.h │ ├── HCDCashNormal.h │ ├── AppDelegate.h │ ├── HCDCaseReturn.h │ ├── HCDCashRobate.h │ ├── HCDCashNormal.m │ ├── HCDCashBase.h │ ├── main.m │ ├── HCDCashContext.h │ ├── HCDCaseReturn.m │ ├── HCDCashRobate.m │ └── Images.xcassets │ └── AppIcon.appiconset │ └── Contents.json ├── 3装饰模式 ├── .DS_Store ├── 3装饰模式 │ ├── 装饰模式图片.jpg │ ├── ConcreteComponent.h │ ├── ConcreteDecoratorB.h │ ├── Component.m │ ├── ViewController.h │ ├── Component.h │ ├── Decorator.h │ ├── AppDelegate.h │ ├── ConcreteComponent.m │ ├── Decorator.m │ ├── ConcreteDecoratorA.h │ ├── main.m │ ├── ConcreteDecoratorA.m │ ├── ConcreteDecoratorB.m │ └── Images.xcassets │ │ └── AppIcon.appiconset │ │ └── Contents.json └── 3装饰模式.xcodeproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ ├── yifan.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── huangchengdu.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 1简单工厂模式 ├── .DS_Store ├── 1简单工厂模式 │ ├── CommonTool.m │ ├── ViewController.h │ ├── HCDCalculateAdd.h │ ├── HCDCalculateMinus.h │ ├── HCDCalculateDivide.h │ ├── HCDCalcuteMultiply.h │ ├── AppDelegate.h │ ├── main.m │ ├── HCDCalcuteFactory.h │ ├── HCDCalculateMinus.m │ ├── HCDCalcuteMultiply.m │ ├── CommonTool.h │ ├── HCDCalculateAdd.m │ ├── HCDCalculateDivide.m │ └── HCDCalculate.h └── 1简单工厂模式.xcodeproj │ ├── project.xcworkspace │ ├── xcuserdata │ │ ├── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata │ └── xcuserdata │ ├── yifan.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── huangchengdu.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 5工厂方法模式 ├── .DS_Store ├── 5工厂方法模式 │ ├── HCDfactory.m │ ├── HCDfactoryAdd.h │ ├── HCDfactoryDivide.h │ ├── HCDfactoryMinus.h │ ├── HCDfactoryMultiply.h │ ├── ViewController.h │ ├── HCDCalculateAdd.h │ ├── HCDCalculateMinus.h │ ├── HCDCalculateDivide.h │ ├── HCDCalcuteMultiply.h │ ├── HCDfactory.h │ ├── AppDelegate.h │ ├── HCDfactoryAdd.m │ ├── HCDfactoryMinus.m │ ├── HCDfactoryDivide.m │ ├── HCDfactoryMultiply.m │ ├── main.m │ ├── HCDCalculateAdd.m │ ├── HCDCalculate.h │ ├── HCDCalculateMinus.m │ ├── HCDCalcuteMultiply.m │ ├── HCDCalculateDivide.m │ └── ViewController.m └── 5工厂方法模式.xcodeproj │ ├── project.xcworkspace │ ├── xcuserdata │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata │ └── xcuserdata │ └── yifan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 17桥接模式 ├── 17桥接模式 │ ├── 桥接模式.png │ ├── HCDPhone.m │ ├── HCDNokiaPhone.h │ ├── ViewController.h │ ├── HCDGameSoftware.h │ ├── HCDPlaySoftWare.h │ ├── HCDWorkSoftWare.h │ ├── AppDelegate.h │ ├── main.m │ ├── HCDSoftware.h │ ├── HCDWorkSoftWare.m │ ├── HCDGameSoftware.m │ ├── HCDPlaySoftWare.m │ ├── HCDPhone.h │ └── Images.xcassets │ │ └── AppIcon.appiconset │ │ └── Contents.json └── 17桥接模式.xcodeproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── yifan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 21享元模式 ├── 21享元模式 │ ├── 享元模式.png │ ├── HCDUser.m │ ├── ViewController.h │ ├── HCDUser.h │ ├── HCDWebSite.h │ ├── AppDelegate.h │ ├── HCDConcreteWebSite.h │ ├── HCDConcreteWebSite.m │ ├── main.m │ ├── HCDWebSiteFactory.h │ └── Images.xcassets │ │ └── AppIcon.appiconset │ │ └── Contents.json └── 21享元模式.xcodeproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── yifan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── huangchengdu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ ├── yifan.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── huangchengdu.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 11状态模式 ├── 11状态模式 │ ├── 状态模式结构图.png │ ├── ViewController.h │ ├── HCDNoonState.h │ ├── HCDRestState.h │ ├── HCDSleepState.h │ ├── HCDState.h │ ├── HCDAfternoonState.h │ ├── HCDForenoonState.h │ ├── AppDelegate.h │ ├── HCDEventState.h │ ├── HCDRestState.m │ ├── HCDSleepState.m │ ├── main.m │ ├── HCDWork.h │ ├── HCDWork.m │ ├── HCDNoonState.m │ ├── HCDForenoonState.m │ ├── HCDAfternoonState.m │ ├── HCDEventState.m │ └── Images.xcassets │ │ └── AppIcon.appiconset │ │ └── Contents.json └── 11状态模式.xcodeproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── yifan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 13备忘录模式 ├── 13备忘录模式 │ ├── 备忘录模式.png │ ├── HCDGameState.m │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── HCDGameState.h │ ├── HCDStateManager.h │ ├── HCDStateManager.m │ └── HCDGameRoll.h └── 13备忘录模式.xcodeproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── huangchengdu.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 19职责链模式 ├── 19职责链模式 │ ├── 职责链模式.png │ ├── HCDReuquest.m │ ├── HCDCommonManager.h │ ├── HCDMajorManager.h │ ├── HCDGenaralManager.h │ ├── ViewController.h │ ├── AppDelegate.h │ ├── HCDReuquest.h │ ├── main.m │ ├── HCDMnager.h │ ├── HCDMnager.m │ ├── HCDMajorManager.m │ ├── HCDCommonManager.m │ └── HCDGenaralManager.m └── 19职责链模式.xcodeproj │ ├── project.xcworkspace │ ├── xcuserdata │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata │ └── xcuserdata │ └── yifan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 20中介者模式 ├── 20中介者模式 │ ├── 中介者模式.png │ ├── Mediator.m │ ├── Colleague.m │ ├── ConcreteColleague1.h │ ├── ConcreteColleague2.h │ ├── ViewController.h │ ├── ConcreteMediator.h │ ├── AppDelegate.h │ ├── main.m │ ├── Colleague.h │ ├── Mediator.h │ ├── HCDMediatorProtocal.h │ ├── ConcreteMediator.m │ ├── ConcreteColleague2.m │ └── ConcreteColleague1.m └── 20中介者模式.xcodeproj │ ├── project.xcworkspace │ ├── xcuserdata │ │ ├── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata │ └── xcuserdata │ ├── yifan.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── huangchengdu.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 9观察者模式 ├── 9观察者模式 │ ├── 观察者模式类图.png │ ├── HCDSecreteSubject.h │ ├── ViewController.h │ ├── HCDObserver.h │ ├── HCDNBAObserver.h │ ├── HCDStockObserver.h │ ├── HCDNBAObserver.m │ ├── HCDStockObserver.m │ ├── AppDelegate.h │ ├── main.m │ ├── HCDSecreteSubject.m │ └── HCDSubject.h └── 9观察者模式.xcodeproj │ ├── project.xcworkspace │ ├── xcuserdata │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata │ └── xcuserdata │ └── yifan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 10抽象工厂模式 ├── 10抽象工厂模式 │ ├── SQLUser.m │ ├── SQLDepartment.m │ ├── SQLUser.h │ ├── SQLDepartment.h │ ├── ViewController.h │ ├── HCDSqlserverUser.h │ ├── HCDAccessFactory.h │ ├── HCDSqlserverFactory.h │ ├── HCDAccessUser.h │ ├── HCDAccessDepartment.h │ ├── HCDUser.h │ ├── HCDSqlserverDepartment.h │ ├── AppDelegate.h │ ├── HCDFactory.h │ ├── HCDDepartment.h │ ├── main.m │ ├── HCDAccessUser.m │ ├── HCDSqlserverUser.m │ ├── HCDAccessFactory.m │ ├── HCDAccessDepartment.m │ ├── HCDSqlserverFactory.m │ └── HCDSqlserverDepartment.m └── 10抽象工厂模式.xcodeproj │ ├── project.xcworkspace │ ├── xcuserdata │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata │ └── xcuserdata │ └── yifan.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 4代理模式 ├── 4代理模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 4代理模式 │ ├── HCDschoolGirl.m │ ├── ViewController.h │ ├── HCDschoolGirl.h │ ├── AppDelegate.h │ ├── HCDgiveGift.h │ ├── HCDproxy.h │ ├── HCDpursuit.h │ ├── main.m │ ├── HCDpursuit.m │ └── Images.xcassets │ └── AppIcon.appiconset │ └── Contents.json ├── 7外观模式 ├── 7外观模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 7外观模式 │ ├── ViewController.h │ ├── HCDstock1.h │ ├── HCDstock2.h │ ├── HCDstock3.h │ ├── HCDFound.h │ ├── HCDstock1.m │ ├── HCDstock2.m │ ├── HCDstock3.m │ ├── AppDelegate.h │ ├── main.m │ ├── ViewController.m │ └── Images.xcassets │ └── AppIcon.appiconset │ └── Contents.json ├── 14组合模式 ├── 14组合模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 14组合模式 │ ├── ViewController.h │ ├── AppDelegate.h │ ├── HCDCompany.h │ ├── HCDHRDepartment.h │ ├── main.m │ ├── HCDConcreteCompany.h │ ├── HCDFinanceDepartment.h │ ├── HCDHRDepartment.m │ ├── HCDFinanceDepartment.m │ └── Images.xcassets │ └── AppIcon.appiconset │ └── Contents.json ├── 16单列模式 ├── 16单列模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 16单列模式 │ ├── ViewController.h │ ├── HCDSingleton.h │ ├── AppDelegate.h │ ├── main.m │ ├── HCDSingleton.m │ ├── ViewController.m │ └── Images.xcassets │ └── AppIcon.appiconset │ └── Contents.json ├── 18命令模式 ├── 18命令模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── yifan.xcuserdatad │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 18命令模式 │ ├── HCDDuckOrder.h │ ├── HCDMuttonOrder.h │ ├── HCDChickenOrder.h │ ├── ViewController.h │ ├── AppDelegate.h │ ├── HCDDuckOrder.m │ ├── HCDMuttonOrder.m │ ├── HCDChickenOrder.m │ ├── main.m │ ├── HCDOrder.m │ ├── HCDWorker.h │ ├── HCDWaiter.h │ ├── HCDOrder.h │ ├── HCDCustomr.h │ ├── HCDWorker.m │ └── Images.xcassets │ └── AppIcon.appiconset │ └── Contents.json ├── 24原型模式 ├── 24原型模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 24原型模式 │ ├── ViewController.h │ ├── Dot.h │ ├── Verter.h │ ├── AppDelegate.h │ ├── main.m │ └── Mark.h ├── 8建造者模式 ├── 8建造者模式.xcodeproj │ ├── project.xcworkspace │ │ ├── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 8建造者模式 │ ├── HCDArm.h │ ├── HCDBody.h │ ├── HCDLeg.h │ ├── HCDHeader.h │ ├── ViewController.h │ ├── HCDArm.m │ ├── HCDLeg.m │ ├── HCDBody.m │ ├── HCDHeader.m │ ├── HCDPersonFatBuilder.h │ ├── HCDPersonThinBuilder.h │ ├── AppDelegate.h │ ├── main.m │ ├── HCDPersonBuilderDirector.h │ ├── HCDPersonBuilderDirector.m │ ├── HCDPresionBuilder.h │ └── Images.xcassets │ └── AppIcon.appiconset │ └── Contents.json ├── 12适配器模式 ├── 12适配器模式.xcodeproj │ ├── project.xcworkspace │ │ ├── xcuserdata │ │ │ ├── yifan.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── huangchengdu.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ ├── yifan.xcuserdatad │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 12适配器模式 │ ├── HCDForwards.h │ ├── ViewController.h │ ├── HCDTranslator.h │ ├── AppDelegate.h │ ├── HCDForwards.m │ ├── HCDPlayer.h │ ├── main.m │ ├── HCDPlayer.m │ ├── HCDForeignCenter.h │ ├── HCDForeignCenter.m │ └── HCDTranslator.m ├── 15迭代器模式 ├── 15迭代器模式.xcodeproj │ ├── project.xcworkspace │ │ ├── xcuserdata │ │ │ ├── yifan.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── huangchengdu.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ ├── yifan.xcuserdatad │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 15迭代器模式 │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ └── ViewController.m ├── 6模板方法模式 ├── 6模板方法模式.xcodeproj │ ├── project.xcworkspace │ │ ├── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 6模板方法模式 │ ├── HCDtextPaperA.h │ ├── HCDtextPaperB.h │ ├── ViewController.h │ ├── AppDelegate.h │ ├── HCDtextPaperA.m │ ├── HCDtextPaperB.m │ ├── HCDtextPaper.h │ ├── main.m │ └── HCDtextPaper.m ├── 22解释器模式 ├── 22解释器模式.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 22解释器模式 │ ├── ViewController.h │ ├── HCDTerminalExpression.h │ ├── HCDNonterminalExpression.h │ ├── HCDAbstractExpression.m │ ├── AppDelegate.h │ ├── HCDAbstractExpression.h │ ├── HCDTerminalExpression.m │ ├── main.m │ ├── HCDContext.h │ ├── HCDNonterminalExpression.m │ └── HCDContext.m └── 23访问者模式 ├── 23访问者模式.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── huangchengdu.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── 23访问者模式 ├── HCDConcreteVisitor1.h ├── HCDConcreteVisitor2.h ├── ViewController.h ├── HCDConcreteElementB.h ├── HCDConcreteElementA.h ├── HCDElements.m ├── HCDElements.h ├── AppDelegate.h ├── main.m ├── HCDConcreteElementB.m ├── HCDConcreteElementA.m ├── HCDVisitors.h ├── HCDVisitors.m ├── HCDConcreteVisitor2.m ├── HCDObjectStructure.h └── HCDConcreteVisitor1.m /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /设计图/中介者模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/中介者模式.png -------------------------------------------------------------------------------- /设计图/享元模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/享元模式.png -------------------------------------------------------------------------------- /设计图/代理模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/代理模式.png -------------------------------------------------------------------------------- /设计图/单列模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/单列模式.png -------------------------------------------------------------------------------- /设计图/原型模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/原型模式.png -------------------------------------------------------------------------------- /设计图/命令模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/命令模式.png -------------------------------------------------------------------------------- /设计图/备忘录模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/备忘录模式.png -------------------------------------------------------------------------------- /设计图/外观模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/外观模式.png -------------------------------------------------------------------------------- /设计图/工厂方法模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/工厂方法模式.png -------------------------------------------------------------------------------- /设计图/建造者模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/建造者模式.png -------------------------------------------------------------------------------- /设计图/抽象工厂模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/抽象工厂模式.png -------------------------------------------------------------------------------- /设计图/桥接模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/桥接模式.png -------------------------------------------------------------------------------- /设计图/模板方法模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/模板方法模式.png -------------------------------------------------------------------------------- /设计图/状态模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/状态模式.png -------------------------------------------------------------------------------- /设计图/策略模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/策略模式.png -------------------------------------------------------------------------------- /设计图/简单工厂模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/简单工厂模式.png -------------------------------------------------------------------------------- /设计图/组合模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/组合模式.png -------------------------------------------------------------------------------- /设计图/装饰模式.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/装饰模式.jpg -------------------------------------------------------------------------------- /设计图/观察者模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/观察者模式.png -------------------------------------------------------------------------------- /设计图/解释器模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/解释器模式.png -------------------------------------------------------------------------------- /设计图/访问者模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/访问者模式.png -------------------------------------------------------------------------------- /设计图/责任链模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/责任链模式.png -------------------------------------------------------------------------------- /设计图/迭代器模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/迭代器模式.png -------------------------------------------------------------------------------- /设计图/适配器模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/设计图/适配器模式.png -------------------------------------------------------------------------------- /2策略模式/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/2策略模式/.DS_Store -------------------------------------------------------------------------------- /3装饰模式/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/3装饰模式/.DS_Store -------------------------------------------------------------------------------- /1简单工厂模式/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/1简单工厂模式/.DS_Store -------------------------------------------------------------------------------- /5工厂方法模式/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/5工厂方法模式/.DS_Store -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/桥接模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/17桥接模式/17桥接模式/桥接模式.png -------------------------------------------------------------------------------- /21享元模式/21享元模式/享元模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/21享元模式/21享元模式/享元模式.png -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/装饰模式图片.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/3装饰模式/3装饰模式/装饰模式图片.jpg -------------------------------------------------------------------------------- /11状态模式/11状态模式/状态模式结构图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/11状态模式/11状态模式/状态模式结构图.png -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/备忘录模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/13备忘录模式/13备忘录模式/备忘录模式.png -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/职责链模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/19职责链模式/19职责链模式/职责链模式.png -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/中介者模式.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/20中介者模式/20中介者模式/中介者模式.png -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/观察者模式类图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/9观察者模式/9观察者模式/观察者模式类图.png -------------------------------------------------------------------------------- /21享元模式/21享元模式/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDPhone.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPhone.m 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPhone.h" 10 | 11 | @implementation HCDPhone 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/SQLUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // SQLUser.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "SQLUser.h" 10 | 11 | @implementation SQLUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/CommonTool.m: -------------------------------------------------------------------------------- 1 | // 2 | // CommonTool.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "CommonTool.h" 10 | 11 | @implementation CommonTool 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/Mediator.m: -------------------------------------------------------------------------------- 1 | // 2 | // Mediator.m 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Mediator.h" 10 | 11 | @implementation Mediator 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /2策略模式/2策略模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /2策略模式/2策略模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/2策略模式/2策略模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /3装饰模式/3装饰模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/3装饰模式/3装饰模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /4代理模式/4代理模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4代理模式/4代理模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/4代理模式/4代理模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactory.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactory.m 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactory.h" 10 | 11 | @implementation HCDfactory 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /7外观模式/7外观模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /7外观模式/7外观模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/7外观模式/7外观模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /11状态模式/11状态模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /11状态模式/11状态模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/11状态模式/11状态模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /14组合模式/14组合模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /16单列模式/16单列模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /16单列模式/16单列模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/16单列模式/16单列模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /17桥接模式/17桥接模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/17桥接模式/17桥接模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /18命令模式/18命令模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /18命令模式/18命令模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/18命令模式/18命令模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDReuquest.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDReuquest.m 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDReuquest.h" 10 | 11 | @implementation HCDReuquest 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/Colleague.m: -------------------------------------------------------------------------------- 1 | // 2 | // Colleague.m 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Colleague.h" 10 | 11 | @implementation Colleague 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /21享元模式/21享元模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /21享元模式/21享元模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/21享元模式/21享元模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /24原型模式/24原型模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/8建造者模式/8建造者模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /9观察者模式/9观察者模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/9观察者模式/9观察者模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /12适配器模式/12适配器模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/12适配器模式/12适配器模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDForwards.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDForwards.h 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPlayer.h" 10 | 11 | @interface HCDForwards : HCDPlayer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/HCDGameState.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDGameState.m 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDGameState.h" 10 | 11 | @implementation HCDGameState 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/15迭代器模式/15迭代器模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDNokiaPhone.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDNokiaPhone.h 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPhone.h" 10 | 11 | @interface HCDNokiaPhone : HCDPhone 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/19职责链模式/19职责链模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/1简单工厂模式/1简单工厂模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /20中介者模式/20中介者模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/20中介者模式/20中介者模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /4代理模式/4代理模式/HCDschoolGirl.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDschoolGirl.m 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDschoolGirl.h" 10 | 11 | @implementation HCDschoolGirl 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/5工厂方法模式/5工厂方法模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/6模板方法模式/6模板方法模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /8建造者模式/8建造者模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/10抽象工厂模式/10抽象工厂模式.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/SQLDepartment.m: -------------------------------------------------------------------------------- 1 | // 2 | // SQLDepartment.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "SQLDepartment.h" 10 | 11 | @implementation SQLDepartment 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/SQLUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // SQLUser.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SQLUser : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDDuckOrder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDDuckOrder.h 3 | // 18命令模式 4 | // 5 | // Created by huangchengdu on 17/6/1. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDOrder.h" 10 | 11 | @interface HCDDuckOrder : HCDOrder 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDMuttonOrder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDMuttonOrder.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDOrder.h" 10 | 11 | @interface HCDMuttonOrder : HCDOrder 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /2策略模式/2策略模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/2策略模式/2策略模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /14组合模式/14组合模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/14组合模式/14组合模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDChickenOrder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDChickenOrder.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDOrder.h" 10 | 11 | @interface HCDChickenOrder : HCDOrder 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /21享元模式/21享元模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/21享元模式/21享元模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /24原型模式/24原型模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/24原型模式/24原型模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryAdd.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryAdd.h 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactory.h" 10 | 11 | @interface HCDfactoryAdd : HCDfactory 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/12适配器模式/12适配器模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/13备忘录模式/13备忘录模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/15迭代器模式/15迭代器模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDCommonManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCommonManager.h 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDMnager.h" 10 | 11 | @interface HCDCommonManager : HCDMnager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDMajorManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDMajorManager.h 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDMnager.h" 10 | 11 | @interface HCDMajorManager : HCDMnager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/1简单工厂模式/1简单工厂模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /20中介者模式/20中介者模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/20中介者模式/20中介者模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /22解释器模式/22解释器模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/22解释器模式/22解释器模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /23访问者模式/23访问者模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/Design-Pattern-For-iOS/HEAD/23访问者模式/23访问者模式.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryDivide.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryAdd.h 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactory.h" 10 | 11 | @interface HCDfactoryDivide : HCDfactory 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryMinus.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryMinus.h 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactory.h" 10 | 11 | @interface HCDfactoryMinus : HCDfactory 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/HCDtextPaperA.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDtextPaperA.h 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDtextPaper.h" 10 | 11 | @interface HCDtextPaperA : HCDtextPaper 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/HCDtextPaperB.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDtextPaperB.h 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDtextPaper.h" 10 | 11 | @interface HCDtextPaperB : HCDtextPaper 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/SQLDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // SQLDepartment.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SQLDepartment : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDGenaralManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDGenaralManager.h 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDMnager.h" 10 | 11 | @interface HCDGenaralManager : HCDMnager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/ConcreteComponent.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteComponent.h 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Component.h" 10 | 11 | @interface ConcreteComponent : Component 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/ConcreteDecoratorB.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteDecoratorB.h 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Decorator.h" 10 | 11 | @interface ConcreteDecoratorB : Decorator 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryMultiply.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryMinus.h 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactory.h" 10 | 11 | @interface HCDfactoryMultiply : HCDfactory 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDSecreteSubject.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSecreteSubject.h 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDSubject.h" 10 | 11 | @interface HCDSecreteSubject : HCDSubject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/ConcreteColleague1.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteColleague1.h 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Colleague.h" 10 | 11 | @interface ConcreteColleague1 : Colleague 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/ConcreteColleague2.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteColleague2.h 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Colleague.h" 10 | 11 | @interface ConcreteColleague2 : Colleague 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteVisitor1.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteVisitor1.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDVisitors.h" 10 | 11 | @interface HCDConcreteVisitor1 : HCDVisitors 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteVisitor2.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteVisitor2.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDVisitors.h" 10 | 11 | @interface HCDConcreteVisitor2 : HCDVisitors 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/Component.m: -------------------------------------------------------------------------------- 1 | // 2 | // Component.m 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Component.h" 10 | 11 | @implementation Component 12 | 13 | - (void)operation{ 14 | 15 | } 16 | @end 17 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 3装饰模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDArm.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDArm.h 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDArm : NSObject 12 | 13 | -(void)work; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDBody.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDBody.h 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDBody : NSObject 12 | 13 | -(void)work; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDLeg.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDLeg.h 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDLeg : NSObject 12 | 13 | -(void)work; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 12适配器模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 15迭代器模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /16单列模式/16单列模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 16单列模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 20中介者模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/Component.h: -------------------------------------------------------------------------------- 1 | // 2 | // Component.h 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Component : NSObject 12 | 13 | -(void)operation; 14 | @end 15 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/HCDstock1.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDstock1.h 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDstock1 : NSObject 12 | -(void)buy; 13 | -(void)sell; 14 | @end 15 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/HCDstock2.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDstock2.h 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDstock2 : NSObject 12 | -(void)buy; 13 | -(void)sell; 14 | @end 15 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/HCDstock3.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDstock3.h 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDstock3 : NSObject 12 | -(void)buy; 13 | -(void)sell; 14 | @end 15 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDHeader.h 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDHeader : NSObject 12 | 13 | -(void)work; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteElementB.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDElementB.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDElements.h" 10 | 11 | @interface HCDConcreteElementB : HCDElements 12 | -(void)operationB; 13 | @end 14 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/HCDFound.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDFound.h 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDFound : NSObject 12 | -(void)buyFund; 13 | -(void)sellFund; 14 | @end 15 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDObserver.h 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol HCDObserver 12 | @optional 13 | -(void)update; 14 | @end 15 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDNoonState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDNoonState.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDState.h" 11 | @interface HCDNoonState : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDRestState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDRestState.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDState.h" 11 | @interface HCDRestState : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /16单列模式/16单列模式/HCDSingleton.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSingleton.h 3 | // 16单列模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDSingleton : NSObject 12 | +(instancetype)sharedInstance; 13 | @end 14 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDUser : NSObject 12 | @property(nonatomic,strong)NSString *name; 13 | @end 14 | -------------------------------------------------------------------------------- /24原型模式/24原型模式/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 24原型模式 4 | // 5 | // Created by huangchengdu on 17/5/16. 6 | // Copyright © 2017年 huangchengdu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDSleepState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSleepState.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDState.h" 11 | @interface HCDSleepState : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDTerminalExpression.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDTerminalExpression.h 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDAbstractExpression.h" 10 | 11 | @interface HCDTerminalExpression : HCDAbstractExpression 12 | @end 13 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteElementA.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteElementA.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDElements.h" 10 | 11 | @interface HCDConcreteElementA : HCDElements 12 | -(void)operationA; 13 | @end 14 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCashNormal.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCashNormal.h 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCashBase.h" 11 | @interface HCDCashNormal : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDState.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDWork; 11 | @protocol HCDState 12 | -(void)writeProgram:(HCDWork *)work; 13 | @end 14 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/HCDWebSite.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWebSite.h 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDUser.h" 11 | @protocol HCDWebSite 12 | -(void)use:(HCDUser *)user; 13 | @end 14 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDArm.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDArm.m 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDArm.h" 10 | 11 | @implementation HCDArm 12 | 13 | -(void)work{ 14 | NSLog(@"成功构建了手臂------HCDArm"); 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDLeg.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDLeg.m 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDLeg.h" 10 | 11 | @implementation HCDLeg 12 | 13 | -(void)work{ 14 | NSLog(@"成功构建了腿------HCDLeg"); 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDAfternoonState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAfternoonState.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDState.h" 11 | @interface HCDAfternoonState : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDForenoonState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDForenoonState.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDState.h" 11 | @interface HCDForenoonState : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDElements.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDElements.m 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDElements.h" 10 | 11 | @implementation HCDElements 12 | -(void)accept:(HCDVisitors *)visitor{ 13 | return; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/HCDschoolGirl.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDschoolGirl.h 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDschoolGirl : NSObject 12 | @property(nonatomic,strong)NSString *name; 13 | @end 14 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDBody.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDBody.m 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDBody.h" 10 | 11 | @implementation HCDBody 12 | 13 | -(void)work{ 14 | NSLog(@"成功构建了身体-----HCDBody"); 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDNBAObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDNBAObserver.h 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDObserver.h" 11 | @interface HCDNBAObserver : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDSqlserverUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSqlserverUser.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDUser.h" 11 | @interface HCDSqlserverUser : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/ConcreteMediator.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteMediator.h 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Mediator.h" 10 | 11 | @class Colleague; 12 | 13 | @interface ConcreteMediator : Mediator 14 | 15 | 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDNonterminalExpression.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDNonterminalEXPRESSION.h 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDAbstractExpression.h" 10 | 11 | @interface HCDNonterminalExpression : HCDAbstractExpression 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalculateAdd.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateAdd.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDCalculateAdd : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDHeader.m 3 | // 8建造者模式 4 | // 5 | // Created by huangchengdu on 17/5/17. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDHeader.h" 10 | 11 | @implementation HCDHeader 12 | 13 | -(void)work{ 14 | NSLog(@"成功构建了头-----HCDHead"); 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDStockObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStockObserver.h 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDObserver.h" 11 | @interface HCDStockObserver : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDAccessFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAccessFactory.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDFactory.h" 11 | @interface HCDAccessFactory : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalculateAdd.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateAdd.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | 12 | @interface HCDCalculateAdd : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalculateMinus.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateMinus.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDCalculateMinus : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /24原型模式/24原型模式/Dot.h: -------------------------------------------------------------------------------- 1 | // 2 | // Dot.h 3 | // 24原型模式 4 | // 5 | // Created by huangchengdu on 17/5/16. 6 | // Copyright © 2017年 huangchengdu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "Mark.h" 12 | 13 | @interface Dot : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/Decorator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Decorator.h 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Component.h" 10 | 11 | @interface Decorator : Component 12 | //装饰对象需要装饰的原始对象 13 | @property(nonatomic, strong)Component *component; 14 | @end 15 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalculateMinus.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateMinus.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDCalculateMinus : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDNBAObserver.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDNBAObserver.m 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDNBAObserver.h" 10 | 11 | @implementation HCDNBAObserver 12 | -(void)update{ 13 | NSLog(@"擦,老板回来了,待会儿继续看NBA"); 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDSqlserverFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUserFactory.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDFactory.h" 11 | @interface HCDSqlserverFactory : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDGameSoftware.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDGameSoftware.h 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDSoftware.h" 11 | 12 | 13 | @interface HCDGameSoftware : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDPlaySoftWare.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPlaySoftWare.h 3 | // 17桥接模式 4 | // 5 | // Created by huangchengdu on 17/5/18. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDSoftware.h" 11 | 12 | @interface HCDPlaySoftWare : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDWorkSoftWare.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWorkSoftWare.h 3 | // 17桥接模式 4 | // 5 | // Created by huangchengdu on 17/5/18. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDSoftware.h" 11 | 12 | @interface HCDWorkSoftWare : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalculateDivide.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateDivide.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDCalculateDivide : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalcuteMultiply.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalcuteMultiply.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDCalcuteMultiply : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalculateDivide.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateDivide.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDCalculateDivide : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalcuteMultiply.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalcuteMultiply.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDCalcuteMultiply : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDStockObserver.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStockObserver.m 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDStockObserver.h" 10 | 11 | @implementation HCDStockObserver 12 | -(void)update{ 13 | NSLog(@"操。。老板回来了,带会儿再看"); 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDAccessUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAccessUser.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDUser.h" 11 | #import "SQLUser.h" 12 | @interface HCDAccessUser : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/HCDstock1.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDstock1.m 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDstock1.h" 10 | 11 | @implementation HCDstock1 12 | -(void)buy{ 13 | NSLog(@"买入股票1"); 14 | } 15 | -(void)sell{ 16 | NSLog(@"卖出股票1"); 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/HCDstock2.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDstock2.m 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDstock2.h" 10 | 11 | @implementation HCDstock2 12 | -(void)buy{ 13 | NSLog(@"买入股票2"); 14 | } 15 | -(void)sell{ 16 | NSLog(@"卖出股票2"); 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/HCDstock3.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDstock3.m 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDstock3.h" 10 | 11 | @implementation HCDstock3 12 | -(void)buy{ 13 | NSLog(@"买入股票3"); 14 | } 15 | -(void)sell{ 16 | NSLog(@"卖出股票3"); 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDAccessDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAccessDepartment.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDDepartment.h" 11 | @interface HCDAccessDepartment : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SQLUser.h" 11 | @protocol HCDUser 12 | -(void)insertUser:(SQLUser *)user; 13 | -(SQLUser *)getUser; 14 | @end 15 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDElements.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDElements.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class HCDVisitors; 12 | 13 | @interface HCDElements : NSObject 14 | -(void)accept:(HCDVisitors *)visitor; 15 | @end 16 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactory.h 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | @interface HCDfactory : NSObject 12 | -(id)createFactory; 13 | @end 14 | -------------------------------------------------------------------------------- /24原型模式/24原型模式/Verter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Verter.h 3 | // 24原型模式 4 | // 5 | // Created by huangchengdu on 17/5/16. 6 | // Copyright © 2017年 huangchengdu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "Mark.h" 12 | 13 | 14 | @interface Verter : NSObject 15 | 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDPersonFatBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPersonFatBuilder.h 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDPresionBuilder.h" 11 | 12 | @interface HCDPersonFatBuilder : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDSqlserverDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSqlserverDepartment.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDDepartment.h" 11 | @interface HCDSqlserverDepartment : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDTranslator.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDTranslator.h 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPlayer.h" 10 | @class HCDForeignCenter; 11 | @interface HCDTranslator : HCDPlayer 12 | @property(nonatomic,strong)HCDForeignCenter *foreigncenter; 13 | @end 14 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDPersonThinBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPersonThinBuilder.h 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDPresionBuilder.h" 11 | 12 | @interface HCDPersonThinBuilder : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /16单列模式/16单列模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 16单列模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDAbstractExpression.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAbstractExpression.m 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDAbstractExpression.h" 10 | 11 | @implementation HCDAbstractExpression 12 | -(void)interpret:(HCDContext *)context{ 13 | return; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 3装饰模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 12适配器模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 15迭代器模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 20中介者模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDAbstractExpression.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAbstractExpression.h 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDContext.h" 11 | @interface HCDAbstractExpression : NSObject 12 | -(void)interpret:(HCDContext *)context; 13 | @end 14 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCaseReturn.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCaseReturn.h 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCashBase.h" 11 | @interface HCDCaseReturn : NSObject 12 | -(instancetype)initWithMoneyReturn:(CGFloat)moneyReturn; 13 | @end 14 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCashRobate.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCashRobate.h 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCashBase.h" 11 | @interface HCDCashRobate : NSObject 12 | -(instancetype)initWithMoneyRebate:(CGFloat)moneyRebate; 13 | @end 14 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDEventState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDEventState.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDState.h" 11 | #import "HCDRestState.h" 12 | #import "HCDSleepState.h" 13 | @interface HCDEventState : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCashNormal.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCashNormal.m 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCashNormal.h" 10 | 11 | @implementation HCDCashNormal 12 | 13 | //@synthesize money = _money; 14 | 15 | -(CGFloat)acceptCash:(CGFloat)cash{ 16 | return cash; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/ConcreteComponent.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteComponent.m 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ConcreteComponent.h" 10 | 11 | @implementation ConcreteComponent 12 | 13 | - (void)operation{ 14 | NSLog(@"ConcreteComponent具体对象的操作,装饰之前"); 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/Decorator.m: -------------------------------------------------------------------------------- 1 | // 2 | // Decorator.m 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Decorator.h" 10 | 11 | @implementation Decorator 12 | 13 | -(void)operation{ 14 | if (self.component) { 15 | [self.component operation]; 16 | } 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDRestState.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDRestState.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDRestState.h" 10 | #import "HCDWork.h" 11 | @implementation HCDRestState 12 | - (void)writeProgram:(HCDWork *)work { 13 | NSLog(@"当前时间:{%.f}点,下班回家了", work.hour); 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDReuquest.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDReuquest.h 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDReuquest : NSObject 12 | @property(nonatomic,copy)NSString *requestType; 13 | @property(nonatomic,assign)NSInteger number; 14 | @end 15 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/HCDConcreteWebSite.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteWebSite.h 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDWebSite.h" 11 | @interface HCDConcreteWebSite : NSObject 12 | @property(nonatomic,strong)NSString *webName; 13 | @end 14 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/HCDConcreteWebSite.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteWebSite.m 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDConcreteWebSite.h" 10 | 11 | @implementation HCDConcreteWebSite 12 | -(void)use:(HCDUser *)user{ 13 | NSLog(@"网站分类:%@,用户:%@",self.webName,user.name); 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /24原型模式/24原型模式/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 24原型模式 4 | // 5 | // Created by huangchengdu on 17/5/16. 6 | // Copyright © 2017年 huangchengdu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCashBase.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCashBase.h 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @protocol HCDCashBase 12 | //@property(nonatomic,assign)CGFloat money; 13 | -(CGFloat)acceptCash:(CGFloat)cash; 14 | @end 15 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/ConcreteDecoratorA.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteDecoratorA.h 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Decorator.h" 10 | 11 | @interface ConcreteDecoratorA : Decorator 12 | //本类独有属性,区别于ConcreteDecoratorB这个装饰者 13 | @property(nonatomic, copy)NSString *addedState; 14 | @end 15 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/HCDtextPaperA.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDtextPaperA.m 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDtextPaperA.h" 10 | 11 | @implementation HCDtextPaperA 12 | -(NSString *)answer1{ 13 | return @"b"; 14 | } 15 | -(NSString *)answer2{ 16 | return @"c"; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/HCDtextPaperB.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDtextPaperB.m 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDtextPaperB.h" 10 | 11 | @implementation HCDtextPaperB 12 | -(NSString *)answer1{ 13 | return @"a"; 14 | } 15 | -(NSString *)answer2{ 16 | return @"d"; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDSleepState.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSleepState.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDSleepState.h" 10 | #import "HCDWork.h" 11 | @implementation HCDSleepState 12 | - (void)writeProgram:(HCDWork *)work { 13 | NSLog(@"当前时间:{%.f}点,不行了,睡着了", work.hour); 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDForwards.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDForwards.m 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDForwards.h" 10 | 11 | @implementation HCDForwards 12 | -(void)attack{ 13 | NSLog(@"前锋%@进攻",self.name); 14 | } 15 | -(void)defense{ 16 | NSLog(@"前锋%@防守",self.name); 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryAdd.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryAdd.m 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactoryAdd.h" 10 | #import "HCDCalculateAdd.h" 11 | @implementation HCDfactoryAdd 12 | -(id)createFactory{ 13 | return [[HCDCalculateAdd alloc]init]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/HCDtextPaper.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDtextPaper.h 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDtextPaper : NSObject 12 | - (void)testQuestion1; 13 | - (NSString *)answer1; 14 | - (void)testQuestion2; 15 | - (NSString *)answer2; 16 | @end 17 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDDuckOrder.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDDuckOrder.m 3 | // 18命令模式 4 | // 5 | // Created by huangchengdu on 17/6/1. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDDuckOrder.h" 10 | 11 | @implementation HCDDuckOrder 12 | 13 | -(void)executeOrder{ 14 | NSLog(@"烤鸭"); 15 | [[HCDWorker sharedWorker] doChickenWork:self.orderString]; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDFactory.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDUser.h" 11 | #import "HCDDepartment.h" 12 | @protocol HCDFactory 13 | -(id)createUser; 14 | -(id)createDepartment; 15 | @end 16 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDMuttonOrder.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDMuttonOrder.m 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDMuttonOrder.h" 10 | 11 | @implementation HCDMuttonOrder 12 | 13 | -(void)executeOrder{ 14 | NSLog(@"烤羊"); 15 | [[HCDWorker sharedWorker] doMuttonWork:self.orderString]; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryMinus.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryMinus.m 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactoryMinus.h" 10 | #import "HCDCalculateMinus.h" 11 | @implementation HCDfactoryMinus 12 | -(id)createFactory{ 13 | return [[HCDCalculateMinus alloc]init]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDDepartment.h 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SQLDepartment.h" 11 | @protocol HCDDepartment 12 | -(void)insertDepartment:(SQLDepartment *)department; 13 | -(SQLDepartment *)getDepartment; 14 | @end 15 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDPlayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPlayer.h 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPlayer : NSObject 12 | @property(nonatomic,copy)NSString *name; 13 | -(void)attack; 14 | -(void)defense; 15 | -(instancetype)initWithName:(NSString *)name; 16 | @end 17 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/HCDCompany.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCompany.h 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol HCDCompany 12 | 13 | -(void)add:(id)company; 14 | -(void)remove:(id)company; 15 | -(void)display; 16 | -(void)lineofDuty; 17 | @end 18 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDChickenOrder.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDChickenOrder.m 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDChickenOrder.h" 10 | 11 | @implementation HCDChickenOrder 12 | 13 | -(void)executeOrder{ 14 | NSLog(@"烤鸡"); 15 | [[HCDWorker sharedWorker] doChickenWork:self.orderString]; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDTerminalExpression.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDTerminalExpression.m 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDTerminalExpression.h" 10 | 11 | @implementation HCDTerminalExpression 12 | -(void)interpret:(HCDContext *)context{ 13 | NSLog(@"终端解释器,context == %@",context.output); 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/HCDgiveGift.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDgiveGift.h 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol HCDgiveGift 12 | /// 送洋娃娃 13 | - (void)giveDolls; 14 | 15 | /// 送鲜花 16 | - (void)giveFlowers; 17 | 18 | /// 送巧克力 19 | - (void)giveChocolate; 20 | @end 21 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/HCDproxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDproxy.h 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDgiveGift.h" 11 | @class HCDschoolGirl,HCDpursuit; 12 | @interface HCDproxy : NSObject 13 | -(instancetype)initWithSchoolGirl:(HCDschoolGirl *)schoolGirl; 14 | @end 15 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryDivide.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryAdd.m 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactoryDivide.h" 10 | #import "HCDCalculateDivide.h" 11 | @implementation HCDfactoryDivide 12 | -(id)createFactory{ 13 | return [[HCDCalculateDivide alloc]init]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/HCDHRDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDDepartment.h 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCompany.h" 11 | @interface HCDHRDepartment : NSObject 12 | @property(nonatomic,copy)NSString *name; 13 | -(instancetype)initWithName:(NSString *)name; 14 | @end 15 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /16单列模式/16单列模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 16单列模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 3装饰模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/HCDpursuit.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDpursuit.h 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDgiveGift.h" 11 | @class HCDschoolGirl; 12 | 13 | @interface HCDpursuit : NSObject 14 | 15 | -(instancetype)initWithSchoolGirl:(HCDschoolGirl *)schoolGirl; 16 | @end 17 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDfactoryMultiply.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDfactoryMinus.m 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDfactoryMultiply.h" 10 | #import "HCDCalcuteMultiply.h" 11 | @implementation HCDfactoryMultiply 12 | -(id)createFactory{ 13 | return [[HCDCalcuteMultiply alloc]init]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 12适配器模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 15迭代器模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 20中介者模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDPlayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPlayer.m 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPlayer.h" 10 | 11 | @implementation HCDPlayer 12 | -(instancetype)initWithName:(NSString *)name{ 13 | self = [super init]; 14 | if (self) { 15 | _name = name; 16 | } 17 | return self; 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDContext.h 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDContext : NSObject 12 | -(instancetype)initWithInput:(NSString *)input; 13 | @property(nonatomic,copy)NSString *input; 14 | @property(nonatomic,copy)NSString *output; 15 | @end 16 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDNonterminalExpression.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDNonterminalEXPRESSION.m 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDNonterminalExpression.h" 10 | 11 | @implementation HCDNonterminalExpression 12 | -(void)interpret:(HCDContext *)context { 13 | NSLog(@"非终端解释器,context == %@",context.output); 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalculateAdd.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateAdd.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalculateAdd.h" 10 | @implementation HCDCalculateAdd 11 | @synthesize numberA = _numberA; 12 | @synthesize numberB = _numberB; 13 | -(CGFloat)calculate{ 14 | return self.numberA + self.numberB; 15 | } 16 | @end 17 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/HCDGameState.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDGameState.h 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDGameState : NSObject 12 | @property(nonatomic,assign)NSInteger life; 13 | @property(nonatomic,assign)NSInteger attack; 14 | @property(nonatomic,assign)NSInteger defeat; 15 | @end 16 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/HCDConcreteCompany.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteCompany.h 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCompany.h" 11 | @interface HCDConcreteCompany : NSObject 12 | @property(nonatomic,copy)NSString *name; 13 | -(instancetype)initWithName:(NSString *)name; 14 | @end 15 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/HCDFinanceDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDFinanceDepartment.h 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCompany.h" 11 | @interface HCDFinanceDepartment : NSObject 12 | @property(nonatomic,copy)NSString *name; 13 | -(instancetype)initWithName:(NSString *)name; 14 | @end -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalcuteFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalcuteFactory.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCalculate.h" 11 | 12 | 13 | @class CommonTool; 14 | @interface HCDCalcuteFactory : NSObject 15 | 16 | +(id)createCalcute:(NSString *)calculatetype; 17 | @end 18 | -------------------------------------------------------------------------------- /24原型模式/24原型模式/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 24原型模式 4 | // 5 | // Created by huangchengdu on 17/5/16. 6 | // Copyright © 2017年 huangchengdu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalculate.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateProtecal.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @protocol HCDCalculate 12 | 13 | @property(nonatomic)CGFloat numberA; 14 | @property(nonatomic)CGFloat numberB; 15 | -(CGFloat)calculate; 16 | @end 17 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/HCDStateManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStateManager.h 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDGameState; 11 | @interface HCDStateManager : NSObject 12 | @property(nonatomic,strong)HCDGameState *gameState; 13 | -(instancetype)initWithGameState:(HCDGameState *)gameState; 14 | @end 15 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalculateMinus.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateMinus.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalculateMinus.h" 10 | 11 | @implementation HCDCalculateMinus 12 | @synthesize numberA = _numberA; 13 | @synthesize numberB = _numberB; 14 | -(CGFloat)calculate{ 15 | return self.numberA - self.numberB; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalculateMinus.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateMinus.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalculateMinus.h" 10 | 11 | @implementation HCDCalculateMinus 12 | @synthesize numberA = _numberA; 13 | @synthesize numberB = _numberB; 14 | -(CGFloat)calculate{ 15 | return self.numberA - self.numberB; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDForeignCenter.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDForeignCenter.h 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDForeignCenter : NSObject 12 | @property(nonatomic,copy)NSString *name; 13 | -(void)foreignAttact; 14 | -(void)foreignDefent; 15 | -(instancetype)initWithName:(NSString *)name; 16 | @end 17 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDOrder.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDOrder.m 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDOrder.h" 10 | 11 | @implementation HCDOrder 12 | -(instancetype)initWithOrderString:(NSString *)orderString{ 13 | self = [super init]; 14 | if (self) { 15 | _orderString = orderString; 16 | } 17 | return self; 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDWorker.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWorker.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDWorker : NSObject 12 | 13 | +(instancetype)sharedWorker; 14 | 15 | -(void)doMuttonWork:(NSString *)work; 16 | -(void)doChickenWork:(NSString *)work; 17 | -(void)doDuckWork:(NSString *)work; 18 | @end 19 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalcuteMultiply.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalcuteMultiply.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalcuteMultiply.h" 10 | 11 | @implementation HCDCalcuteMultiply 12 | @synthesize numberA = _numberA; 13 | @synthesize numberB = _numberB; 14 | -(CGFloat)calculate{ 15 | return self.numberA * self.numberB; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalcuteMultiply.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalcuteMultiply.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalcuteMultiply.h" 10 | 11 | @implementation HCDCalcuteMultiply 12 | @synthesize numberA = _numberA; 13 | @synthesize numberB = _numberB; 14 | -(CGFloat)calculate{ 15 | return self.numberA * self.numberB; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/CommonTool.h: -------------------------------------------------------------------------------- 1 | // 2 | // CommonTool.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, CalculateType){ 12 | calcuteTypeAdd = 0, 13 | calcuteTypeMinus, 14 | calcuteTypdeMultipy, 15 | calcuteTypeDivide 16 | }; 17 | 18 | @interface CommonTool : NSObject 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDSoftware.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSoftware.h 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol HCDSoftware 12 | -(void)runQQ; 13 | -(void)runWeixin; 14 | -(void)runWord; 15 | -(void)runXcode; 16 | -(void)runQQDizhu; 17 | -(void)runQQMajiang; 18 | @end 19 | 20 | typedef id HCDSoftware; 21 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/ConcreteDecoratorA.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteDecoratorA.m 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ConcreteDecoratorA.h" 10 | 11 | @implementation ConcreteDecoratorA 12 | 13 | -(void)operation{ 14 | [super operation]; 15 | self.addedState = @"New State"; 16 | NSLog(@"ConcreteDecoratorA添加的装饰功能,相当于对Component进行装饰"); 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDPersonBuilderDirector.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPersonBuilderDirector.h 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDPresionBuilder.h" 11 | 12 | @interface HCDPersonBuilderDirector : NSObject 13 | 14 | 15 | @property(nonatomic, strong)HCDPresionBuilder builder; 16 | 17 | -(void)buildPerson; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/HCDStateManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStateManager.m 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDStateManager.h" 10 | 11 | @implementation HCDStateManager 12 | -(instancetype)initWithGameState:(HCDGameState *)gameState{ 13 | self = [super init]; 14 | if (self) { 15 | _gameState = gameState; 16 | } 17 | return self; 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDAccessUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAccessUser.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDAccessUser.h" 10 | 11 | @implementation HCDAccessUser 12 | -(SQLUser *)getUser{ 13 | NSLog(@"新建一个Access的SQLUser对象"); 14 | return [[SQLUser alloc]init]; 15 | } 16 | -(void)insertUser:(SQLUser *)user{ 17 | NSLog(@"插入一个Access的SQLUser对象"); 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDWaiter.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWaiter.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDOrder.h" 11 | #import "HCDMuttonOrder.h" 12 | #import "HCDChickenOrder.h" 13 | 14 | @interface HCDWaiter : NSObject 15 | 16 | -(void)addOrder:(HCDOrder *)order; 17 | -(void)deleteOrder:(HCDOrder *)order; 18 | -(void)notifyOrder; 19 | @end 20 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteElementB.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDElementB.m 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDConcreteElementB.h" 10 | #import "HCDVisitors.h" 11 | 12 | 13 | @implementation HCDConcreteElementB 14 | 15 | -(void)operationB{ 16 | return; 17 | } 18 | -(void)accept:(HCDVisitors *)visitor{ 19 | [visitor visitConcreteElementB:self]; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteElementA.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteElementA.m 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDConcreteElementA.h" 10 | #import "HCDVisitors.h" 11 | 12 | 13 | @implementation HCDConcreteElementA 14 | 15 | -(void)operationA{ 16 | return; 17 | } 18 | -(void)accept:(HCDVisitors *)visitor{ 19 | [visitor visitConcreteElementA:self]; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDWork.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWork.h 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "HCDState.h" 12 | @interface HCDWork : NSObject 13 | @property(nonatomic,strong)id state; 14 | @property(nonatomic,assign)CGFloat hour; 15 | @property(nonatomic,assign)BOOL finished; 16 | -(void)writeProgram; 17 | @end 18 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDOrder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDOrder.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDOrder.h" 11 | #import "HCDWorker.h" 12 | 13 | @interface HCDOrder : NSObject 14 | 15 | @property(nonatomic,copy)NSString *orderString; 16 | 17 | -(instancetype)initWithOrderString:(NSString *)orderString; 18 | //执行命令 19 | -(void)executeOrder; 20 | @end 21 | -------------------------------------------------------------------------------- /21享元模式/21享元模式/HCDWebSiteFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWebSiteFactory.h 3 | // 21享元模式 4 | // 5 | // Created by yifan on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDWebSite.h" 11 | 12 | 13 | @interface HCDWebSiteFactory : NSObject 14 | @property(nonatomic,strong)NSDictionary *flyweights; 15 | 16 | -(id )getWebSiteCategory:(NSString *)webkey; 17 | -(NSInteger)getWebSiteCount; 18 | @end 19 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDSecreteSubject.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSecreteSubject.m 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDSecreteSubject.h" 10 | #import "HCDObserver.h" 11 | 12 | @implementation HCDSecreteSubject 13 | -(void)notify{ 14 | NSLog(@"秘书通知:老板回来了,大家赶紧撤"); 15 | for (id observer in [self getobserverList]) { 16 | [observer update]; 17 | } 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDSqlserverUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSqlserverUser.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDSqlserverUser.h" 10 | 11 | @implementation HCDSqlserverUser 12 | -(SQLUser *)getUser{ 13 | NSLog(@"新建一个Sqlserver的SQLUser对象"); 14 | return [[SQLUser alloc]init]; 15 | } 16 | -(void)insertUser:(SQLUser *)user{ 17 | NSLog(@"插入一个Sqlserver的SQLUser对象"); 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/ConcreteDecoratorB.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteDecoratorB.m 3 | // 3装饰模式 4 | // 5 | // Created by huangchengdu on 17/5/25. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ConcreteDecoratorB.h" 10 | 11 | @implementation ConcreteDecoratorB 12 | 13 | - (void)operation{ 14 | [super operation]; 15 | [self addedBehavior]; 16 | } 17 | 18 | - (void)addedBehavior{ 19 | NSLog(@"ConcreteDecoratorB添加的装饰功能,相当于对Component进行装饰"); 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDMnager.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDMnager.h 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDMnager,HCDReuquest; 11 | @interface HCDMnager : NSObject 12 | @property(nonatomic,copy)NSString *name; 13 | @property(nonatomic,strong)HCDMnager *superior; 14 | -(instancetype)initWithName:(NSString *)name; 15 | -(void)dealRequest:(HCDReuquest *)request; 16 | @end 17 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalculateAdd.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateAdd.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalculateAdd.h" 10 | @implementation HCDCalculateAdd 11 | 12 | /** 13 | * 下面这两句话会自动生成实现的协议的属性对应的成员变量。如果没有这两句话,则系统会奔溃 14 | */ 15 | @synthesize numberA = _numberA; 16 | @synthesize numberB = _numberB; 17 | 18 | -(CGFloat)calculate{ 19 | return self.numberA + self.numberB; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/Colleague.h: -------------------------------------------------------------------------------- 1 | // 2 | // Colleague.h 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class Mediator; 12 | @interface Colleague : NSObject 13 | 14 | @property(nonatomic, strong)Mediator *mediator; 15 | 16 | -(instancetype)initWithMediator:(Mediator *)mediator; 17 | 18 | -(void)notify:(NSString *)message; 19 | -(void)send:(NSString *)message; 20 | @end 21 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDMnager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDMnager.m 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDMnager.h" 10 | #import "HCDReuquest.h" 11 | @implementation HCDMnager 12 | -(instancetype)initWithName:(NSString *)name{ 13 | self = [super init]; 14 | if (self) { 15 | _name = name; 16 | } 17 | return self; 18 | } 19 | -(void)dealRequest:(HCDReuquest *)request{ 20 | 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/Mediator.h: -------------------------------------------------------------------------------- 1 | // 2 | // Mediator.h 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class Colleague; 12 | 13 | @interface Mediator : NSObject 14 | 15 | @property(nonatomic, strong)Colleague *colleague1; 16 | @property(nonatomic, strong)Colleague *colleague2; 17 | 18 | -(void)send:(NSString *)message colleague:(Colleague *)colleague; 19 | 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalculateDivide.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateDivide.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalculateDivide.h" 10 | 11 | @implementation HCDCalculateDivide 12 | @synthesize numberA = _numberA; 13 | @synthesize numberB = _numberB; 14 | -(CGFloat)calculate{ 15 | if (self.numberB == 0) { 16 | assert(self.numberB); 17 | } 18 | return self.numberA/self.numberB; 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/HCDCalculateDivide.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateDivide.m 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCalculateDivide.h" 10 | 11 | @implementation HCDCalculateDivide 12 | @synthesize numberA = _numberA; 13 | @synthesize numberB = _numberB; 14 | -(CGFloat)calculate{ 15 | if (self.numberB == 0) { 16 | assert(self.numberB); 17 | } 18 | return self.numberA/self.numberB; 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDWorkSoftWare.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWorkSoftWare.m 3 | // 17桥接模式 4 | // 5 | // Created by huangchengdu on 17/5/18. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDWorkSoftWare.h" 10 | #import "HCDSoftware.h" 11 | 12 | @interface HCDWorkSoftWare () 13 | 14 | @end 15 | 16 | @implementation HCDWorkSoftWare 17 | 18 | -(void)runWord{ 19 | NSLog(@"WorkSoftWare打开办公软件"); 20 | } 21 | 22 | -(void)runXcode{ 23 | NSLog(@"WorkSoftWare打开Xcode"); 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式/HCDContext.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDContext.m 3 | // 22解释器模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDContext.h" 10 | 11 | @implementation HCDContext 12 | -(instancetype)initWithInput:(NSString *)input{ 13 | self = [super init]; 14 | if (self) { 15 | _input = input; 16 | } 17 | return self; 18 | } 19 | -(NSString *)output{ 20 | return [NSString stringWithFormat:@"输入的是%@",_input]; 21 | } 22 | @end 23 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDVisitors.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDVisitors.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDConcreteElementA.h" 11 | #import "HCDConcreteElementB.h" 12 | 13 | 14 | @interface HCDVisitors : NSObject 15 | 16 | 17 | -(void)visitConcreteElementA:(HCDConcreteElementA *)concreteElementA; 18 | -(void)visitConcreteElementB:(HCDConcreteElementB *)concreteElementB; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDWork.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWork.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDWork.h" 10 | #import "HCDForenoonState.h" 11 | @implementation HCDWork 12 | -(instancetype)init{ 13 | self = [super init]; 14 | if (self) { 15 | self.state = [[HCDForenoonState alloc]init]; 16 | } 17 | return self; 18 | } 19 | 20 | -(void)writeProgram{ 21 | [self.state writeProgram:self]; 22 | } 23 | @end 24 | -------------------------------------------------------------------------------- /16单列模式/16单列模式/HCDSingleton.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSingleton.m 3 | // 16单列模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDSingleton.h" 10 | 11 | @implementation HCDSingleton 12 | +(instancetype)sharedInstance{ 13 | static HCDSingleton *singleton = nil; 14 | static dispatch_once_t onceToken; 15 | dispatch_once(&onceToken, ^{ 16 | singleton = [[HCDSingleton alloc]init]; 17 | }); 18 | return singleton; 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDGameSoftware.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDGameSoftware.m 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDGameSoftware.h" 10 | #import "HCDSoftware.h" 11 | 12 | @interface HCDGameSoftware () 13 | 14 | @end 15 | 16 | @implementation HCDGameSoftware 17 | 18 | -(void)runQQDizhu{ 19 | NSLog(@"GameSoftware开始QQ斗地主"); 20 | } 21 | 22 | -(void)runQQMajiang{ 23 | NSLog(@"GameSoftware开始QQ麻将"); 24 | } 25 | @end 26 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDAccessFactory.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAccessFactory.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDAccessFactory.h" 10 | #import "HCDAccessDepartment.h" 11 | #import "HCDAccessUser.h" 12 | @implementation HCDAccessFactory 13 | -(id)createUser{ 14 | return [[HCDAccessUser alloc]init]; 15 | } 16 | -(id)createDepartment{ 17 | return [[HCDAccessDepartment alloc]init]; 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDPlaySoftWare.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPlaySoftWare.m 3 | // 17桥接模式 4 | // 5 | // Created by huangchengdu on 17/5/18. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPlaySoftWare.h" 10 | #import "HCDSoftware.h" 11 | 12 | @interface HCDPlaySoftWare () 13 | 14 | @end 15 | 16 | @implementation HCDPlaySoftWare 17 | 18 | -(void)runQQ{ 19 | NSLog(@"PlaySoftWare开始打开QQ"); 20 | } 21 | 22 | -(void)runWeixin{ 23 | NSLog(@"PlaySoftWare开始打开微信"); 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDVisitors.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDVisitors.m 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDVisitors.h" 10 | #import "HCDConcreteElementA.h" 11 | #import "HCDConcreteElementB.h" 12 | 13 | @implementation HCDVisitors 14 | 15 | -(void)visitConcreteElementA:(HCDConcreteElementA *)concreteElementA{ 16 | return; 17 | } 18 | -(void)visitConcreteElementB:(HCDConcreteElementB *)concreteElementB{ 19 | return; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式/HCDSubject.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSubject.h 3 | // 9观察者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDObserver.h" 11 | @interface HCDSubject : NSObject 12 | //这里很不合理,不知怎么办 13 | //@property(nonatomic,readwrite,strong)NSMutableArray *observerList; 14 | -(void)attach:(id)observer; 15 | -(void)detach:(id)observer; 16 | -(void)notify; 17 | -(NSArray *)getobserverList; 18 | @end 19 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDAccessDepartment.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAccessDepartment.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDAccessDepartment.h" 10 | 11 | @implementation HCDAccessDepartment 12 | -(SQLDepartment *)getDepartment{ 13 | NSLog(@"新建一个Access的SQLDepartment对象"); 14 | return [[SQLDepartment alloc]init]; 15 | } 16 | -(void)insertDepartment:(SQLDepartment *)department{ 17 | NSLog(@"插入一个Access的SQLDepartment对象"); 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式/HCDCalculate.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCalculateProtecal.h 3 | // 1简单工厂模式 4 | // 5 | // Created by 黄成都 on 15/8/10. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | /** 12 | * 协议声明出来的是方法,虽然看起来是属性,其实只有 getter、setter 这两个方法,内部是没有实例变量的,并且你不能去重定义它,只能在 getter、setter 里处理 13 | */ 14 | @protocol HCDCalculate 15 | 16 | @property(nonatomic)CGFloat numberA; 17 | @property(nonatomic)CGFloat numberB; 18 | 19 | -(CGFloat)calculate; 20 | @end 21 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDCustomr.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCustomr.h 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class HCDOrder,HCDMuttonOrder,HCDChickenOrder; 12 | 13 | typedef NS_ENUM(NSUInteger,orderType){ 14 | orderTypeMutton, 15 | orderTypeChicken, 16 | orderTypeDuck 17 | }; 18 | 19 | @interface HCDCustomr : NSObject 20 | 21 | -(HCDOrder *)pushOrderWithString:(NSString *)string type:(orderType)type; 22 | @end 23 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDSqlserverFactory.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUserFactory.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDSqlserverFactory.h" 10 | #import "HCDSqlserverUser.h" 11 | #import "HCDSqlserverDepartment.h" 12 | @implementation HCDSqlserverFactory 13 | -(id)createUser{ 14 | return [[HCDSqlserverUser alloc]init]; 15 | } 16 | -(id)createDepartment{ 17 | return [[HCDSqlserverDepartment alloc]init]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式/HCDSqlserverDepartment.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDSqlserverDepartment.m 3 | // 10抽象工厂模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDSqlserverDepartment.h" 10 | 11 | @implementation HCDSqlserverDepartment 12 | -(SQLDepartment *)getDepartment{ 13 | NSLog(@"新建一个Sqlserver的SQLDepartment对象"); 14 | return [[SQLDepartment alloc]init]; 15 | } 16 | -(void)insertDepartment:(SQLDepartment *)department{ 17 | NSLog(@"插入一个Sqlserver的SQLDepartment对象"); 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式/HCDGameRoll.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDGameRoll.h 3 | // 13备忘录模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDGameState; 11 | @interface HCDGameRoll : NSObject 12 | @property(nonatomic,assign)NSInteger life; 13 | @property(nonatomic,assign)NSInteger attack; 14 | @property(nonatomic,assign)NSInteger defeat; 15 | -(void)getState; 16 | -(HCDGameState *)saveState; 17 | -(void)fightBoss; 18 | -(void)rebackState:(HCDGameState *)state; 19 | @end 20 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 15迭代器模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteVisitor2.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteVisitor2.m 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDConcreteVisitor2.h" 10 | 11 | @implementation HCDConcreteVisitor2 12 | 13 | -(void)visitConcreteElementA:(HCDConcreteElementA *)concreteElementA{ 14 | NSLog(@"男人接收到怒这个visitor============我要叫"); 15 | } 16 | 17 | -(void)visitConcreteElementB:(HCDConcreteElementB *)concreteElementB{ 18 | NSLog(@"女人接收到怒这个visitor============我要苦"); 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDObjectStructure.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDObjectStructure.h 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class HCDElements; 12 | @class HCDVisitors; 13 | 14 | @interface HCDObjectStructure : NSObject 15 | { 16 | NSMutableArray *elements; 17 | } 18 | //添加和删除element 19 | -(void)attach:(HCDElements *)element; 20 | -(void)detach:(HCDElements *)element; 21 | //接受一个visitor 22 | -(void)accept:(HCDVisitors *)visitor; 23 | @end 24 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDNoonState.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDNoonState.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDNoonState.h" 10 | #import "HCDAfternoonState.h" 11 | #import "HCDWork.h" 12 | @implementation HCDNoonState 13 | -(void)writeProgram:(HCDWork *)work{ 14 | if (work.hour < 13) { 15 | NSLog(@"当前时间:{%.f}点,饿了,午饭;犯困,午休", work.hour); 16 | } else { 17 | work.state = [[HCDAfternoonState alloc] init]; 18 | [work writeProgram]; 19 | } 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDForenoonState.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDForenoonState.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDForenoonState.h" 10 | #import "HCDWork.h" 11 | #import "HCDNoonState.h" 12 | @implementation HCDForenoonState 13 | -(void)writeProgram:(HCDWork *)work{ 14 | if (work.hour < 12) { 15 | NSLog(@"当前时间:{%.f}点,上午工作,精神百倍", work.hour); 16 | }else{ 17 | work.state = [[HCDNoonState alloc] init]; 18 | [work writeProgram]; 19 | } 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式/HCDConcreteVisitor1.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDConcreteVisitor1.m 3 | // 23访问者模式 4 | // 5 | // Created by 黄成都 on 15/8/27. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDConcreteVisitor1.h" 10 | 11 | 12 | @implementation HCDConcreteVisitor1 13 | 14 | -(void)visitConcreteElementA:(HCDConcreteElementA *)concreteElementA{ 15 | NSLog(@"男人接收到喜这个visitor============我要飞"); 16 | } 17 | 18 | -(void)visitConcreteElementB:(HCDConcreteElementB *)concreteElementB{ 19 | NSLog(@"女人接收到喜这个visitor============我要跳"); 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDAfternoonState.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDAfternoonState.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDAfternoonState.h" 10 | #import "HCDEventState.h" 11 | #import "HCDWork.h" 12 | @implementation HCDAfternoonState 13 | -(void)writeProgram:(HCDWork *)work{ 14 | if (work.hour < 17) { 15 | NSLog(@"当前时间:{%.f}点,下午状态还不错,继续努力", work.hour); 16 | } else { 17 | work.state = [[HCDEventState alloc] init]; 18 | [work writeProgram]; 19 | } 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDMajorManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDMajorManager.m 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDMajorManager.h" 10 | #import "HCDReuquest.h" 11 | @implementation HCDMajorManager 12 | -(void)dealRequest:(HCDReuquest *)request{ 13 | if ([request.requestType isEqualToString:@"请假"] && request.number < 50) { 14 | NSLog(@"%@处理了%@,时间是%d",self.name,request.requestType,request.number); 15 | }else{ 16 | [self.superior dealRequest:request]; 17 | } 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDForeignCenter.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDForeignCenter.m 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDForeignCenter.h" 10 | 11 | @implementation HCDForeignCenter 12 | -(instancetype)initWithName:(NSString *)name{ 13 | self = [super init]; 14 | if (self) { 15 | _name = name; 16 | } 17 | return self; 18 | } 19 | 20 | -(void)foreignAttact{ 21 | NSLog(@"外籍中锋%@进攻",self.name); 22 | } 23 | -(void)foreignDefent{ 24 | NSLog(@"外籍中锋%@防守",self.name); 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDCommonManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCommonManager.m 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCommonManager.h" 10 | #import "HCDReuquest.h" 11 | 12 | @implementation HCDCommonManager 13 | -(void)dealRequest:(HCDReuquest *)request{ 14 | if ([request.requestType isEqualToString:@"请假"] && request.number < 10) { 15 | NSLog(@"%@处理了%@,时间是%d",self.name,request.requestType,request.number); 16 | }else{ 17 | [self.superior dealRequest:request]; 18 | } 19 | } 20 | @end 21 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCashContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCashContext.h 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDCashBase.h" 11 | 12 | 13 | typedef NS_ENUM(NSInteger, HCDCashType){ 14 | CashTypeNormal = 0, 15 | CashTypeRobate, 16 | CashTypeReturn 17 | }; 18 | 19 | 20 | @interface HCDCashContext : NSObject 21 | -(instancetype)initWithCashSuper:(id)cashBase; 22 | -(instancetype)initWithCashType:(HCDCashType)type; 23 | -(CGFloat)getResult:(CGFloat)money; 24 | @end 25 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDPersonBuilderDirector.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPersonBuilderDirector.m 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPersonBuilderDirector.h" 10 | #import "HCDPersonFatBuilder.h" 11 | #import "HCDPersonThinBuilder.h" 12 | 13 | 14 | @interface HCDPersonBuilderDirector () 15 | 16 | @end 17 | 18 | @implementation HCDPersonBuilderDirector 19 | 20 | 21 | -(void)buildPerson{ 22 | NSLog(@"===============director指挥builder开始建造===================="); 23 | [self.builder buildPerson]; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/HCDMediatorProtocal.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDMediatorProtocal.h 3 | // 20中介者模式 4 | // 5 | // Created by 黄成都 on 15/8/26. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "HCDAbstractColleague.h" 12 | #import "HCDColleagueB.h" 13 | #import "HCDColleagueA.h" 14 | @protocol HCDMediatorProtocal 15 | -(instancetype)initWithColleagueA:(HCDColleagueA *)colleagueA colleagueB:(HCDColleagueB *)colleagueB; 16 | -(void)setValueToColleagueA:(CGFloat)value; 17 | -(void)setValueToColleagueB:(CGFloat)value; 18 | @end 19 | -------------------------------------------------------------------------------- /16单列模式/16单列模式/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 16单列模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式/HCDGenaralManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDGenaralManager.m 3 | // 19职责链模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDGenaralManager.h" 10 | #import "HCDReuquest.h" 11 | @implementation HCDGenaralManager 12 | -(void)dealRequest:(HCDReuquest *)request{ 13 | if ([request.requestType isEqualToString:@"请假"] && request.number < 500) { 14 | NSLog(@"%@处理了%@,时间是%d",self.name,request.requestType,request.number); 15 | }else{ 16 | NSLog(@"%@不同意%@,时间是%d",self.name,request.requestType,request.number); 17 | } 18 | } 19 | @end 20 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/HCDPresionBuilder.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPresionBuilder.h 3 | // 8建造者模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger,BuildOption){ 12 | BuildFat, 13 | BuildThin 14 | }; 15 | 16 | 17 | 18 | @protocol HCDPresionBuilder 19 | 20 | -(void)buildHead; 21 | -(void)buildBody; 22 | -(void)buildArmLeft; 23 | -(void)buildArmRight; 24 | -(void)buildLegLeft; 25 | -(void)buildLegRight; 26 | 27 | - (void)buildPerson; 28 | 29 | @end 30 | 31 | typedef id HCDPresionBuilder; 32 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/HCDPhone.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPhone.h 3 | // 17桥接模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDSoftware.h" 11 | 12 | @class HCDGameSoftware; 13 | @class HCDPlaySoftWare; 14 | @class HCDWorkSoftWare; 15 | 16 | @interface HCDPhone : NSObject 17 | 18 | @property(nonatomic, strong, readonly)HCDGameSoftware *gameSoft; 19 | @property(nonatomic, strong, readonly)HCDWorkSoftWare *workSoft; 20 | @property(nonatomic, strong, readonly)HCDPlaySoftWare *playSoft; 21 | 22 | -(void)work; 23 | -(void)play; 24 | -(void)game; 25 | @end 26 | -------------------------------------------------------------------------------- /24原型模式/24原型模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 24原型模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4DC94D231ECB1E7700A8DB96 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/ConcreteMediator.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteMediator.m 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ConcreteMediator.h" 10 | #import "ConcreteColleague1.h" 11 | #import "ConcreteColleague2.h" 12 | 13 | @implementation ConcreteMediator 14 | @synthesize colleague1 =_colleague1; 15 | @synthesize colleague2 = _colleague2; 16 | 17 | -(void)send:(NSString *)message colleague:(Colleague *)colleague{ 18 | if (colleague == _colleague1) { 19 | [_colleague2 notify:message]; 20 | }else{ 21 | [_colleague1 notify:message]; 22 | } 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCaseReturn.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCaseReturn.m 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCaseReturn.h" 10 | 11 | @interface HCDCaseReturn () 12 | 13 | @property(nonatomic)CGFloat moneyReturn; 14 | @end 15 | 16 | @implementation HCDCaseReturn 17 | //@synthesize money = _money; 18 | 19 | -(instancetype)initWithMoneyReturn:(CGFloat)moneyReturn{ 20 | self = [super init]; 21 | if (self) { 22 | _moneyReturn = moneyReturn; 23 | } 24 | return self; 25 | } 26 | -(CGFloat)acceptCash:(CGFloat)cash{ 27 | return cash - self.moneyReturn; 28 | } 29 | @end 30 | -------------------------------------------------------------------------------- /2策略模式/2策略模式/HCDCashRobate.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDCashRobate.m 3 | // 2策略模式 4 | // 5 | // Created by 黄成都 on 15/8/11. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDCashRobate.h" 10 | 11 | @interface HCDCashRobate () 12 | @property(nonatomic)CGFloat moneyRebate; 13 | @end 14 | 15 | @implementation HCDCashRobate 16 | //@synthesize money = _money; 17 | -(instancetype)initWithMoneyRebate:(CGFloat)moneyRebate{ 18 | self = [super init]; 19 | if (self) { 20 | _moneyRebate = moneyRebate; 21 | } 22 | return self; 23 | } 24 | 25 | -(CGFloat)acceptCash:(CGFloat)cash{ 26 | return self.moneyRebate * cash; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/HCDHRDepartment.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDDepartment.m 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDHRDepartment.h" 10 | 11 | @implementation HCDHRDepartment 12 | -(instancetype)initWithName:(NSString *)name{ 13 | self = [super init]; 14 | if (self) { 15 | _name = name; 16 | } 17 | return self; 18 | } 19 | -(void)add:(id)company{ 20 | 21 | } 22 | -(void)display{ 23 | NSLog(@"%@的HR部门",self.name); 24 | } 25 | -(void)remove:(id)company{ 26 | 27 | } 28 | -(void)lineofDuty{ 29 | NSLog(@"%@,培训员工",self.name); 30 | } 31 | @end 32 | -------------------------------------------------------------------------------- /7外观模式/7外观模式/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 7外观模式 4 | // 5 | // Created by yifan on 15/8/13. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HCDFound.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | 20 | 21 | HCDFound *found = [[HCDFound alloc]init]; 22 | [found buyFund]; 23 | [found sellFund]; 24 | } 25 | 26 | - (void)didReceiveMemoryWarning { 27 | [super didReceiveMemoryWarning]; 28 | // Dispose of any resources that can be recreated. 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式/HCDtextPaper.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDtextPaper.m 3 | // 6模板方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDtextPaper.h" 10 | 11 | @implementation HCDtextPaper 12 | -(void)testQuestion1{ 13 | NSLog(@"问题:杨过得到,后来给了郭靖,炼成倚天剑、屠龙刀的玄铁可能是[ ]:a.球磨铸铁 b.马口铁 c.高速合金钢 d.碳素纤维"); 14 | NSLog(@"答案:%@", [self answer1]); 15 | } 16 | -(NSString *)answer1{ 17 | return nil; 18 | } 19 | -(void)testQuestion2{ 20 | NSLog(@"问题:杨过、程英、陆无双铲除了情花,造成[ ]:a.使这种植物不再害人 b.使一种珍稀物种灭绝 c.破坏了那个生物圈的生态平衡 d.造成该地区沙漠化"); 21 | NSLog(@"答案:%@", [self answer2]); 22 | } 23 | -(NSString *)answer2{ 24 | return nil; 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式/HCDTranslator.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDTranslator.m 3 | // 12适配器模式 4 | // 5 | // Created by 黄成都 on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDTranslator.h" 10 | #import "HCDForeignCenter.h" 11 | 12 | @interface HCDTranslator () 13 | 14 | @end 15 | @implementation HCDTranslator 16 | -(instancetype)initWithName:(NSString *)name{ 17 | self = [super init]; 18 | if (self) { 19 | _foreigncenter = [[HCDForeignCenter alloc]initWithName:name]; 20 | } 21 | return self; 22 | } 23 | 24 | -(void)defense{ 25 | [self.foreigncenter foreignDefent]; 26 | } 27 | -(void)attack{ 28 | [self.foreigncenter foreignAttact]; 29 | } 30 | @end 31 | -------------------------------------------------------------------------------- /14组合模式/14组合模式/HCDFinanceDepartment.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDFinanceDepartment.m 3 | // 14组合模式 4 | // 5 | // Created by 黄成都 on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDFinanceDepartment.h" 10 | 11 | @implementation HCDFinanceDepartment 12 | -(instancetype)initWithName:(NSString *)name{ 13 | self = [super init]; 14 | if (self) { 15 | _name = name; 16 | } 17 | return self; 18 | } 19 | -(void)add:(id)company{ 20 | 21 | } 22 | -(void)display{ 23 | NSLog(@"%@,的财务部门",self.name); 24 | } 25 | -(void)remove:(id)company{ 26 | 27 | } 28 | -(void)lineofDuty{ 29 | NSLog(@"%@,给员工发钱",self.name); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/ConcreteColleague2.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteColleague2.m 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ConcreteColleague2.h" 10 | #import "Mediator.h" 11 | 12 | @implementation ConcreteColleague2 13 | @synthesize mediator = _mediator; 14 | 15 | -(instancetype)initWithMediator:(Mediator *)mediator{ 16 | self = [super init]; 17 | if (self) { 18 | _mediator = mediator; 19 | } 20 | return self; 21 | } 22 | 23 | -(void)send:(NSString *)message{ 24 | NSLog(@"同事2发送了信息"); 25 | [_mediator send:message colleague:self]; 26 | } 27 | 28 | -(void)notify:(NSString *)message{ 29 | NSLog(@"%@%@",@"同事2得到消息", message); 30 | } 31 | @end 32 | -------------------------------------------------------------------------------- /2策略模式/2策略模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 2策略模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D6E52F51B795CCA006999B9 16 | 17 | primary 18 | 19 | 20 | 4D6E530E1B795CCA006999B9 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 3装饰模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD17B1A91B7B058000943EDE 16 | 17 | primary 18 | 19 | 20 | DD17B1C21B7B058000943EDE 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /4代理模式/4代理模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 4代理模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD17B1ED1B7B1B5D00943EDE 16 | 17 | primary 18 | 19 | 20 | DD17B2061B7B1B5D00943EDE 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /7外观模式/7外观模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 7外观模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD4F86711B7C322100A32343 16 | 17 | primary 18 | 19 | 20 | DD4F868A1B7C322200A32343 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /11状态模式/11状态模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 11状态模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD3660B31B7DAA1B00549DFD 16 | 17 | primary 18 | 19 | 20 | DD3660CC1B7DAA1B00549DFD 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/HCDEventState.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDEventState.m 3 | // 11状态模式 4 | // 5 | // Created by yifan on 15/8/14. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDEventState.h" 10 | #import "HCDWork.h" 11 | #import "HCDRestState.h" 12 | #import "HCDSleepState.h" 13 | @implementation HCDEventState 14 | -(void)writeProgram:(HCDWork *)work{ 15 | if (work.finished) { 16 | work.state = [[HCDRestState alloc] init]; 17 | [work writeProgram]; 18 | } else { 19 | if (work.hour < 21) { 20 | NSLog(@"当前时间:{%.f}点,加班哦,疲累之极", work.hour); 21 | } else { 22 | work.state = [[HCDSleepState alloc] init]; 23 | [work writeProgram]; 24 | } 25 | } 26 | 27 | } 28 | @end 29 | -------------------------------------------------------------------------------- /16单列模式/16单列模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 16单列模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D685F1B7ED6F300F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D68781B7ED6F300F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /17桥接模式/17桥接模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 17桥接模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D68951B7ED92400F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D68AE1B7ED92400F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /18命令模式/18命令模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 18命令模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D68E11B7F0E5500F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D68FA1B7F0E5500F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /18命令模式/18命令模式/HCDWorker.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDWorker.m 3 | // 18命令模式 4 | // 5 | // Created by yifan on 15/8/15. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDWorker.h" 10 | 11 | @implementation HCDWorker 12 | 13 | +(instancetype)sharedWorker{ 14 | static dispatch_once_t once; 15 | static HCDWorker *sharedWorker = nil; 16 | dispatch_once(&once, ^{ 17 | sharedWorker = [[HCDWorker alloc]init]; 18 | }); 19 | return sharedWorker; 20 | } 21 | 22 | -(void)doMuttonWork:(NSString *)work{ 23 | NSLog(@"厨师考羊肉:%@",work); 24 | } 25 | -(void)doChickenWork:(NSString *)work{ 26 | NSLog(@"厨师考鸡肉:%@",work); 27 | } 28 | 29 | -(void)doDuckWork:(NSString *)work{ 30 | NSLog(@"厨师烤鸭肉:%@",work); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /21享元模式/21享元模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 21享元模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D699C1B7F40C000F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D69B51B7F40C000F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /8建造者模式/8建造者模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 8建造者模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD4F86B01B7C38C600A32343 16 | 17 | primary 18 | 19 | 20 | DD4F86C91B7C38C600A32343 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /9观察者模式/9观察者模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 9观察者模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DDBEA9A41B7C87BF004874A1 16 | 17 | primary 18 | 19 | 20 | DDBEA9BD1B7C87BF004874A1 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /10抽象工厂模式/10抽象工厂模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 10抽象工厂模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD36605D1B7D8E9600549DFD 16 | 17 | primary 18 | 19 | 20 | DD3660761B7D8E9600549DFD 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 12适配器模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD3660FE1B7DCCAC00549DFD 16 | 17 | primary 18 | 19 | 20 | DD3661171B7DCCAC00549DFD 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /14组合模式/14组合模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 14组合模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D879BA41B7EA00B00DD9ECD 16 | 17 | primary 18 | 19 | 20 | 4D879BBD1B7EA00B00DD9ECD 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 15迭代器模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D879BE81B7EB25700DD9ECD 16 | 17 | primary 18 | 19 | 20 | 4D879C011B7EB25800DD9ECD 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /18命令模式/18命令模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 18命令模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D68E11B7F0E5500F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D68FA1B7F0E5500F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /19职责链模式/19职责链模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 19职责链模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D69261B7F31C100F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D693F1B7F31C100F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 1简单工厂模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D89487E1B78C792008DDDD4 16 | 17 | primary 18 | 19 | 20 | 4D8948971B78C792008DDDD4 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 20中介者模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D696A1B7F409900F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D69831B7F409A00F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /21享元模式/21享元模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 21享元模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D699C1B7F40C000F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D69B51B7F40C000F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /2策略模式/2策略模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 2策略模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D6E52F51B795CCA006999B9 16 | 17 | primary 18 | 19 | 20 | 4D6E530E1B795CCA006999B9 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /3装饰模式/3装饰模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 3装饰模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD17B1A91B7B058000943EDE 16 | 17 | primary 18 | 19 | 20 | DD17B1C21B7B058000943EDE 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 5工厂方法模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD17B22A1B7B2B3B00943EDE 16 | 17 | primary 18 | 19 | 20 | DD17B2431B7B2B3B00943EDE 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /6模板方法模式/6模板方法模式.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 6模板方法模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD17B27A1B7B451F00943EDE 16 | 17 | primary 18 | 19 | 20 | DD17B2931B7B451F00943EDE 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /12适配器模式/12适配器模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 12适配器模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD3660FE1B7DCCAC00549DFD 16 | 17 | primary 18 | 19 | 20 | DD3661171B7DCCAC00549DFD 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /13备忘录模式/13备忘录模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 13备忘录模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4DB85B241B7E2E42007D5B1E 16 | 17 | primary 18 | 19 | 20 | 4DB85B3D1B7E2E43007D5B1E 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /15迭代器模式/15迭代器模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 15迭代器模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D879BE81B7EB25700DD9ECD 16 | 17 | primary 18 | 19 | 20 | 4D879C011B7EB25800DD9ECD 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /1简单工厂模式/1简单工厂模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 1简单工厂模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D89487E1B78C792008DDDD4 16 | 17 | primary 18 | 19 | 20 | 4D8948971B78C792008DDDD4 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 20中介者模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2D696A1B7F409900F9E848 16 | 17 | primary 18 | 19 | 20 | DD2D69831B7F409A00F9E848 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /20中介者模式/20中介者模式/ConcreteColleague1.m: -------------------------------------------------------------------------------- 1 | // 2 | // ConcreteColleague1.m 3 | // 20中介者模式 4 | // 5 | // Created by huangchengdu on 17/5/22. 6 | // Copyright © 2017年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ConcreteColleague1.h" 10 | #import "Mediator.h" 11 | 12 | @implementation ConcreteColleague1 13 | 14 | @synthesize mediator = _mediator; 15 | 16 | -(instancetype)initWithMediator:(Mediator *)mediator{ 17 | self = [super init]; 18 | if (self) { 19 | _mediator = mediator; 20 | } 21 | return self; 22 | } 23 | 24 | -(void)send:(NSString *)message{ 25 | NSLog(@"同事1发送了信息"); 26 | [_mediator send:message colleague:self]; 27 | } 28 | 29 | -(void)notify:(NSString *)message{ 30 | NSLog(@"%@%@",@"同事1得到消息:", message); 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /22解释器模式/22解释器模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 22解释器模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4DC8419E1B8F2FBC00DD1E28 16 | 17 | primary 18 | 19 | 20 | 4DC841B71B8F2FBC00DD1E28 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /23访问者模式/23访问者模式.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 23访问者模式.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4DC841DD1B8F45D500DD1E28 16 | 17 | primary 18 | 19 | 20 | 4DC841F61B8F45D500DD1E28 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /5工厂方法模式/5工厂方法模式/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 5工厂方法模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "HCDCalculate.h" 11 | #import "HCDfactory.h" 12 | #import "HCDCalculateAdd.h" 13 | #import "HCDfactoryAdd.h" 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | HCDfactory *factory = [[HCDfactoryAdd alloc]init]; 23 | HCDfactory *calculate = [factory createFactory]; 24 | calculate.numberA = 10; 25 | calculate.numberB = 15; 26 | NSLog(@"结果是%f",[calculate calculate]); 27 | 28 | 29 | 30 | } 31 | 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /24原型模式/24原型模式/Mark.h: -------------------------------------------------------------------------------- 1 | // 2 | // Mark.h 3 | // 24原型模式 4 | // 5 | // Created by huangchengdu on 17/5/16. 6 | // Copyright © 2017年 huangchengdu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | 14 | 15 | @protocol Mark 16 | 17 | @property (nonatomic, strong) UIColor *color; 18 | @property (nonatomic, assign) CGFloat size; 19 | @property (nonatomic, assign) CGPoint location; 20 | @property (nonatomic, assign, readonly) NSUInteger count; 21 | @property (nonatomic,strong, readonly) id lastChild; 22 | 23 | -(id) initWithLocation:(CGPoint) location; 24 | -(id)copy; 25 | -(void) addMark:(id) mark; 26 | -(void) removeMark:(id) mark; 27 | -(id) childMarkAtIndex:(NSUInteger) index; 28 | @end 29 | -------------------------------------------------------------------------------- /11状态模式/11状态模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /14组合模式/14组合模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /16单列模式/16单列模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /17桥接模式/17桥接模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /18命令模式/18命令模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /21享元模式/21享元模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /2策略模式/2策略模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /3装饰模式/3装饰模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /4代理模式/4代理模式/HCDpursuit.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDpursuit.m 3 | // 4代理模式 4 | // 5 | // Created by yifan on 15/8/12. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDpursuit.h" 10 | #import "HCDschoolGirl.h" 11 | @interface HCDpursuit () 12 | @property(nonatomic,strong)HCDschoolGirl *schoolGirl; 13 | @end 14 | 15 | @implementation HCDpursuit 16 | -(instancetype)initWithSchoolGirl:(HCDschoolGirl *)schoolGirl{ 17 | self = [super init]; 18 | if (self) { 19 | _schoolGirl = schoolGirl; 20 | } 21 | return self; 22 | } 23 | -(void)giveChocolate{ 24 | NSLog(@"送你巧克力%@",self.schoolGirl.name); 25 | } 26 | -(void)giveDolls{ 27 | NSLog(@"送你洋娃娃%@",self.schoolGirl.name); 28 | } 29 | -(void)giveFlowers{ 30 | NSLog(@"送你玫瑰花%@",self.schoolGirl.name); 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /4代理模式/4代理模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /7外观模式/7外观模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /8建造者模式/8建造者模式/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } --------------------------------------------------------------------------------