Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. /*
  2. @synthesize是一个编译器指令, 它可以简化我们getter/setter方法的实现
  3.  
  4. 什么是实现:
  5. 在声明后面写上大括号就代表着实现
  6.  
  7. 1.在@synthesize后面告诉编译器, 需要实现哪个@property生成的声明
  8. 2. 告诉@synthesize, 需要将传入的值赋值给谁和返回谁的值给调用者
  9.  
  10. - (void)setAge:(int)age
  11. {
  12. _age = age;
  13. }
  14. - (int)age
  15. {
  16. return _age;
  17. }
  18. */
  19. //@synthesize age = _age;
  20.  
  21. // 如果在@synthesize后面没有告诉系统将传入的值赋值给谁, 系统默认会赋值给和@synthesize后面写得名称相同的成员变量
  22. // _age? age;
  23. @synthesize age;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement