[程序示例]Objective-C中的委托设计模式(牛仔与姑娘)(二)

2015-01-22 21:12:34 · 作者: · 浏览: 46
[date dateByAddingTimeInterval:6]]; } return 0; }

一切都准备就绪,现在让我们的牛仔拿起枪,行动起来吧!

编译成功!输出结果如下:

2014-07-16 17:27:10.973 Girl&Cowboy[4055:303] Lucy:My name is Lucy,my dad was taken by the bad guys,can you save him,please?

2014-07-16 17:27:11.012 Girl&Cowboy[4055:303] John Marston:OK,young lady,wait for the good news!


2014-07-16 17:27:13.014 Girl&Cowboy[4055:303] John Marston:There are too many of'em,I'll take all of my men and kill them all!!!Wait for the good news!

2014-07-16 17:27:13.015 Girl&Cowboy[4055:303] Lucy:My heart is so broken,I cant live without him,you must save him please,woo woo.



2014-07-16 17:27:15.014 Girl&Cowboy[4055:303] John Marston and his crew:I killed all the bad guys,and here is your father.

2014-07-16 17:27:15.015 Girl&Cowboy[4055:303] Lucy:Thank you so much,marry me~

Program ended with exit code: 0

我们的英雄把姑娘的父亲救出来了并且杀死了坏人!

这个例子很简单,实际应用中会比这个复杂得多,但是希望通过我这个例子能让不了解的同学对委托设计模式有个初步的认识吧~吐舌头