iOS设计模式 - 桥接
2023-09-14 08:57:30 时间
iOS设计模式 - 桥接
示意图
说明
1. 桥接模式为把抽象层次结构从实现中分离出来,使其可以独立变更,抽象层定义了供客户端使用的上层抽象接口,实现层次结构定义了供抽象层次使用的底层接口,实现类的引用被封装于抽象层的实例中,桥接就形成了.
2. 桥接模式可以解决具有功能类似但又不完全相同的某种功能架构,为了能让实现更加灵活.
源码
https://github.com/YouXianMing/iOS-Design-Patterns
// // ConsoleController.h // GameBoy // Created by YouXianMing on 15/7/26. // Copyright (c) 2015年 YouXianMing. All rights reserved. #import Foundation/Foundation.h #import "ConsoleEmulator.h" @interface ConsoleController : NSObject * 抽象模拟器 @property (nonatomic, strong) ConsoleEmulator *emulator; * 执行指令 * @param command 指令 - (void)excuteCommand:(ConsoleCommand)command; @end
// // ConsoleController.h // GameBoy // Created by YouXianMing on 15/7/26. // Copyright (c) 2015年 YouXianMing. All rights reserved. #import Foundation/Foundation.h #import "ConsoleEmulator.h" @interface ConsoleController : NSObject * 抽象模拟器 @property (nonatomic, strong) ConsoleEmulator *emulator; * 执行指令 * @param command 指令 - (void)excuteCommand:(ConsoleCommand)command; @end
// // ConsoleEmulator.h // GameBoy // Created by YouXianMing on 15/7/26. // Copyright (c) 2015年 YouXianMing. All rights reserved. #import Foundation/Foundation.h typedef enum : NSUInteger { kConsoleCommandUp, kConsoleCommandDown, kConsoleCommandLeft, kConsoleCommandRight, kConsoleCommandSelect, kConsoleCommandStart, kConsoleCommandAction1, kConsoleCommandAction2, } ConsoleCommand; @interface ConsoleEmulator : NSObject * 加载指令 * @param command 指令 - (void)loadInstructionsForCommand:(ConsoleCommand)command; * 执行指令 - (void)excuteInstructions; @end
// // ConsoleEmulator.m // GameBoy // Created by YouXianMing on 15/7/26. // Copyright (c) 2015年 YouXianMing. All rights reserved. #import "ConsoleEmulator.h" @implementation ConsoleEmulator - (void)loadInstructionsForCommand:(ConsoleCommand)command { // 由子类重载实现 - (void)excuteInstructions { // 由子类重载实现 @end
分析
桥接模式伦理图
其实,就是抽象的管理类管理一个抽象的执行类,通过一个方法或者多个方法来让抽象执行类完成功能,这就是传说中的桥接模式
淘宝iOS扫一扫架构升级 - 设计模式的应用 本文在“扫一扫功能的不断迭代,基于设计模式的基本原则,逐步采用设计模式思想进行代码和架构优化”的背景下,对设计模式在扫一扫中新的应用进行了总结。
1.外观模式简介 外观模式(Facade)在开发过程中的运用频率非常高,尤其是在现阶段各种第三方SDK充斥在我们的周边,而这些SDK很大概率会使用外观模式。
模型-视图-控制器(Model-View-Controller,MVC)是Xerox PARC在20世纪80年代为编程语言Smalltalk-80发明的一种软件设计模式,至今已广泛应用于用户交互应用程序中。
建议45:设计模式是特定环境下的特定问题的解决方案 设计模式是某种特定设计的模板或指导原则。 建议46:MVC模式是一种复合或聚合模式 MVC 是一种高级别的模式,关注的是应用程序的全局架构,并根据各种对象在程序中发挥的作用对其进行分类。
相关文章
- iOS小技能:因境外IP无法访问导致 App 被拒的解决方案
- iOS 优化 - 瘦身
- 关于iOS打包出现的两例常见问题
- iOS锁屏时钟_ios时钟怎么调
- 用iOS的Siri语音助手快速发布“说说”,源自Typecho handsome主题的时光机。
- iOS swift将文字转为竖排文字
- HBuilder X 连接苹果手机(IOS)详细教程。Windows: 连接iOS手机调试项目
- iOS创建苹果证书、制作p12证书流程
- APP Uploader-iOS APP上架到App Store的辅助工具
- 【iOS 开发】iOS 开发 简介 (IOS项目文件 | MVC 模式 | 事件响应机制 | Storyboard 控制界面 | 代码控制界面 | Retina 屏幕图片适配)
- iOS简易抽屉效果详解手机开发
- iOS获取文件路径详解手机开发
- iOS对图像进行压缩代码详解手机开发
- iOS开发系列课程(05) — 导航视图控制器详解手机开发
- iOS—正确使用NSNotification对象详解手机开发
- 探索Linux系统:在iOS上下载(linux系统ios下载)
- 越狱工具Unc0ver 6.2.0发布!支持部分iOS 14
- iOS 14.5现已发布 新增Face ID便捷解锁和应用跟踪透明化功能
- Win11如何与Android、iOS竞争?微软CEO回应
- Linux下安装iOS:解决方案(linux安装ios)
- 基于Linux环境下iOS应用开发实践(linux下开发ios)
- iOS开发与Linux的技术融合(ios开发linux)
- 探秘iOS:它究竟是一种基于Linux的操作系统吗?(ios是linux系统吗)