iOS design mode-appearance
Schematic diagram
Description
1. When the customer service side needs to use a complex subsystem (the relationship between subsystems is complex), but do not want to have a relationship with them, we need to write a separate class to interact with the subsystem, isolate the client-to-subsystem connection, the client only with this separately written class interaction
2. The appearance mode essentially provides a unified interface for a set of interfaces in the system, and the appearance defines a high-level interface that makes the subsystem easy to use
Source
Https://github.com/YouXianMing/FacadePattern
////ShapeMaker.h//Facadepattern////Created by youxianming on 15/7/28.//Copyright (c) 2015 youxianming. All rights reserved.//#import<Foundation/Foundation.h>#import "Shape.h"#import "Circle.h"#import "Rectangle.h"#import "Square.h"@interfaceShapemaker:nsobject+ (void) Drawcircleandrectangle;+ (void) Drawcircleandsquare;+ (void) Drawall;@end
////SHAPEMAKER.M//Facadepattern////Created by youxianming on 15/7/28.//Copyright (c) 2015 youxianming. All rights reserved.//#import "ShapeMaker.h"@implementationShapemaker+ (void) Drawcircleandrectangle {Shape*circle = [CircleNew]; Shape*rectangle = [RectangleNew]; [Circle Draw]; [Rectangle draw]; NSLog (@"\ n");}+ (void) Drawcircleandsquare {Shape*circle = [CircleNew]; Shape*square = [SquareNew]; [Circle Draw]; [Square Draw]; NSLog (@"\ n");}+ (void) Drawall {Shape*circle = [CircleNew]; Shape*rectangle = [RectangleNew]; Shape*square = [SquareNew]; [Circle Draw]; [Rectangle draw]; [Square Draw]; NSLog (@"\ n");}@end
// // // Facadepattern // // Created by youxianming on 15/7/28.< /span>// Copyright (c) 2015 youxianming. All rights reserved. // #import <foundation/foundation.h>@ Interface Shape:nsobject /* Span style= "color: #008000;" >* * Draw */-(void ) draw; @end
////SHAPE.M//Facadepattern////Created by youxianming on 15/7/28.//Copyright (c) 2015 youxianming. All rights reserved.//#import "Shape.h"@implementationShape- (void) Draw {//overridden by subclasses}@end
Analysis
Detailed comparison
iOS design mode-appearance