Sunday, December 25, 2011

[翻譯文]什麼是delegate(委派)?

在Cocoa Touch, Objective-C,以及 iOS 應用程式中,

當有事件發生時,delegate(委派)讓一個物件可以傳送訊息給另一個物件。

舉例UITextFieldDelegate來說,當一個按鈕被按下時,

Text Field delegate讓鍵盤物件傳送訊息給Text Field物件

然而,什麼時候使用delegate好呢?像是在商業世界一樣,

一個好的delegate(委派)有下面四項優秀技能

1.知道他/她做什麼
2.說“我能做到”
3.有一個計劃
4.讓他們知道

同樣,使用delegate(委派)你必須了解並遵循以下四個步驟。

以先前的例子來說,
1.你必須要按返回按鈕退回鍵盤。
2.UITextFieldDelegate可以使用textFieldShouldReturn方法
3.編寫該方法內容
- (BOOL)textFieldShouldReturn:(UITextField *)aTextField {
 [aTextField resignFirstResponder];
  return YES;
}
4.連結Text Field delegate 到 File’s Owner

英文原文:
http://www.purenewbie.com/?p=230


2 comments:

  1. vimax is a herbal medicine devoted to the men, who serves as the vimax canada permanent and extend appropriate in want, quickly and accurately without side effects and with permanent results, vimax asli has been the choice of international consumers. Vimax PiIls already well known parts of the world and is often used by men to increase male virility and maximize the size of the penis, in order to give satisfaction to their partners. obat pembesar penis Vimax has been recognized by scientists the world as an herbal remedy for pembesar penis and how this increase is no longer a secret mighty man, this is extraordinary usefulness fast, mutually agree and permanent.

    ReplyDelete