iOS design mode-bridging

Source: Internet
Author: User

iOS design mode-bridging

Description

1. Bridging mode to separate the abstract hierarchy from the implementation, so that it can be changed independently, the abstraction layer defines the upper layer of abstraction interface for the client to use, the implementation of the hierarchy defined for the level of abstraction for the use of the underlying interface, the implementation of the class reference is encapsulated in an instance of the abstraction layer, bridging is formed.

2. Bridging mode solves a functional architecture that is functionally similar but not identical, in order to make the implementation more flexible.

Source

Https://github.com/YouXianMing/BridgePattern

////ConsoleController.h//GameBoy////Created by youxianming on 15/7/26.//Copyright (c) 2015 youxianming. All rights reserved.//#import<Foundation/Foundation.h>#import "ConsoleEmulator.h"@interfaceConsolecontroller:nsobject/** Abstract Simulator*/@property (nonatomic, strong) Consoleemulator*emulator;/** * Execute command * * @param command 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"@interfaceConsolecontroller:nsobject/** Abstract Simulator*/@property (nonatomic, strong) Consoleemulator*emulator;/** * Execute command * * @param command 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>typedefenum: Nsuinteger {kconsolecommandup, Kconsolecommanddown, Kconsolecommandleft, Kconsolecommandright, Kconsolecommandselect, Kconsolecommandstart, KConsoleCommandAction1, KConsoleCommandAction2,} Console Command;@interfaceConsoleemulator:nsobject/** * Load Command * * @param command command*/- (void) Loadinstructionsforcommand: (consolecommand) command;/** * Execution Instructions*/- (void) excuteinstructions;@end
////CONSOLEEMULATOR.M//GameBoy////Created by youxianming on 15/7/26.//Copyright (c) 2015 youxianming. All rights reserved.//#import "ConsoleEmulator.h"@implementationConsoleemulator- (void) Loadinstructionsforcommand: (consolecommand) Command {//Subclass Overloading Implementation}- (void) excuteinstructions {//Subclass Overloading Implementation}@end

Analysis

Bridge Mode Ethics Map

In fact, it is an abstract management class that manages an abstract execution class, with a method or methods to let the abstract perform the function of the class, which is the legendary bridging pattern

iOS design mode-bridging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.