[UML] MVC的运作模式

简介

 

最近在研究MVC的运作模式,特别研究了一下IPhone SDK中UIView, UIViewController, UIResponser 的运作模式

同时写了个小范例跟画了个简单的示意用的UML

这个代码是以C#语法写的

 

UML

 

[UML] MVC的运作模式_第1张图片

 

范例代码

 

interface ITouch { void touch(); } class Responser : ITouch { ITouch delegate; public ITouch Delegate { get { return delegate; } set { delegate = value; } } protected void touch() { if(delegate != null) delegate->touch(); } } class UIView : Responser { } class UITestView : UIView { Button btnTest; Label lblTest; public UITestView { btnTest = new Button(); lblTest = new Label(); btnTest.Delegate = this.Delegate; this.Add(btnTest); this.Add(lblTest); } public void ShowText() { lblTest.Text = btnTest.Text; } } class UIViewController : Response { } class UITestViewController : UIViewController { UITestView view; public UIViewController() { view = new UITestView(); view.Delegate = this; } void override touch() { view.ShowText(); } }

你可能感兴趣的:([UML] MVC的运作模式)