Giter Site home page Giter Site logo

factory's Introduction

7/10

Factory Method

运行时动态决定子类的对象

ZHObject:

Des: 单元数据集合
SubClassing: NSObject
Property: ZHPeople *people
		  ZHMessage *message;
Methods:  -(void)bindWithObject:(id<ZHObject>)object;
*IMPORTANT*: 该方法必须由子类重写实现,完成子类数据处理

ZHPeople:

Des: 单元数据(人)
SubClassing: ZHObject
Property:	NSString* name;

ZHMessage:

Des: 单元数据(消息)
SubClassing: ZHObject
Property: NSString *messageContent

ZHFactory

Des: Factory method, create ZHPeople or ZHMessage instance
SubClassing: NSObject
Property: ZHPeople *people;
		  ZHMessage *message;
Methods: + (ZHObject *)Factory:(id<ZHObject>)object;

ZHModel

Des: 实现数据绑定
SubClassing: NSObject
Property: ZHObject *object; 基本数据单元
		  NSArray *objects; 数据集合
Methods: - (void)bindModel:(id<ZHModel>)model;

ZHViewController

Des: 测试

  ZHPeople *people = [[ZHPeople alloc] init];
  people.name = @"Edward";
  
  ZHMessage *message = [[ZHMessage alloc] init];
  message.messageContent = @"The isa instance variable of the new instance is 
  	initialized to a data structure that describes the class; memory for all other 
  	instance variables is set to 0.";
  
  NSArray *objects = @[people,message];
  ZHModel *model = [[ZHModel alloc] init];
  model.objects = objects;
  [model bindModel:model];

factory's People

Contributors

edwardean avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.