新人请教OC中self用法

新人小白,求教下面的获取文本框、标签的文本属性为什么都要用self.num1.text,self.resultLabel.text, 不能直接用num1.text,resultLabel.text???

#import "HMViewController.h"

@interface HMViewController ()
@property (nonatomic, weak) IBOutlet UITextField *num1;
@property (nonatomic, weak) IBOutlet UITextField *num2;
@property (nonatomic, weak) IBOutlet UILabel *resultLabel;

@end

@implementation HMViewController

  • (IBAction)compute
    {
    NSString *num1 = self.num1.text;
    NSString *num2 = self.num2.text;

    int result = num1.intValue + num2.intValue;

    self.resultLabel.text = [NSString stringWithFormat:@"%d", result];

    [self.view endEditing:YES];
    }

@end

http://blog.csdn.net/hahahacff/article/details/39586451

可以用 _ num1.text 来读取
用 self.num 会自动调用 get 方法

可以把self理解成是一个指针自己的对象,类似C++中的this,表示自己

不通过self 是直接访问属性,通过self 是调用了系统默认添加的 setter方法

self 就是指你当前所在对象,self.就是当前对象 的 某些属性, 可以把 点 理解为 的