[obj-c]iOS开发中常见的语句@synthesize obj=_obj的意义详解

 

//
//  POViewController.m
//  Calculator
//
//  Created by hua mao on 12-9-24.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "POViewController.h"

@implementation POViewController
@synthesize display=_display;
//属性绑定到变量 obc 的属性实际上是告诉编译器有这个东西 要对他生成set get
//set get 实际是对_display 操作  既对变量操作。
//@synthesize display;
//如果如上则自动生成同名变量display.


- (IBAction)digitPressed:(UIButton *)sender {
    NSString *str=[sender currentTitle];
    _display.text=str;
    //self.display.text=str;
}
@end
  
 

关于_xxx

根据standford那个IOS教学视频描述。

你只要应该在set get方法体内部中使用_xxx实例变量。

其他地方去使用set get方法来获取。

如 self.xx;      [self xx];

猜你喜欢

转载自poolo.iteye.com/blog/1684081