iOS design mode-templates

Source: Internet
Author: User

iOS design mode-templates

Schematic diagram

Description

Defines the skeleton of an algorithm in an operation, and defers the step to the subclass. The template method allows subclasses to redefine some specific steps of an algorithm without altering the structure of an algorithm.

Source

Https://github.com/YouXianMing/TemplatePattern

////GameProtocol.h//Templatepattern////Created by youxianming on 15/10/27.//copyright©2015 year Zipeiyi. All rights reserved.//#import<Foundation/Foundation.h>@protocolGameprotocol <NSObject>@required/** * Set Number of players * * @param count*/- (void) Setplayercount: (int) count;/** * Returns the number of players * * @return number of players*/- (int) Playercount;/** * Initialize game*/- (void) Initializegame;/** * Start the game*/- (void) Makeplay;/** * End the game*/- (void) Endofgame;@end
// //   Monopoly.h//  templatepattern////  Created by Youxianming on 15/10/27. //   copyright©2015 year Zipeiyi. All rights reserved. // #import <Foundation/Foundation.h>#import"GameProtocol.h"  @interface monopoly:nsobject <GameProtocol>@end
////monopoly.m//Templatepattern////Created by youxianming on 15/10/27.//copyright©2015 year Zipeiyi. All rights reserved.//#import "Monopoly.h"@interfaceMonopoly () @property (nonatomic, assign)intGameplayercount;@end@implementationMonopoly- (void) Setplayercount: (int) Count {self.gameplayercount=count;}- (int) Playercount {returnSelf.gameplayercount;}- (void) initializegame {NSLog (@"Monopoly Initialize");}- (void) Makeplay {NSLog (@"Monopoly Makeplay");}- (void) endofgame {NSLog (@"Monopoly Endofgame");}@end
// //   Chess.h//  templatepattern////  Created by Youxianming on 15/10/27. //   copyright©2015 year Zipeiyi. All rights reserved. // #import <Foundation/Foundation.h>#import"GameProtocol.h"  @interface chess:nsobject <GameProtocol>@end
////CHESS.M//Templatepattern////Created by youxianming on 15/10/27.//copyright©2015 year Zipeiyi. All rights reserved.//#import "Chess.h"@interfaceChess () @property (nonatomic, assign)intGameplayercount;@end@implementationChess- (void) Setplayercount: (int) Count {self.gameplayercount=count;}- (int) Playercount {returnSelf.gameplayercount;}- (void) initializegame {NSLog (@"Chess Initialize");}- (void) Makeplay {NSLog (@"Chess Makeplay");}- (void) endofgame {NSLog (@"Chess Endofgame");}@end

Details

iOS design mode-templates

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.