所以,我剛開始學習Objective-C,並且遇到了這個「自我」的東西。我只用過C,但是我認爲它也可以用在java中呢?有人可以解釋嗎?這裏有一個例子:爲什麼使用「自我」是什麼意思?
- (IBAction)digitPressed:(UIButton *)sender
{
NSString *digit = [sender currentTitle];
UILabel *myDisplay = [self display]; //why this?
}
爲什麼不是這樣?
- (IBAction)digitPressed:(UIButton *)sender
{
NSString *digit = [sender currentTitle];
UILabel *myDisplay = display; //why not like this?
}
顯示器是一個UILabel *
如果您只使用了C語言,並且沒有面向對象的語言,您應該閱讀[*編寫Objective-C代碼*](https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/ RoadMapiOS/chapters/WriteObjective-CCode/WriteObjective-CCode/WriteObjective-CCode.html),是蘋果「開始開發iOS應用程序」指南的一部分。 –