Person.h

#import <Foundation/Foundation.h>

@interface Person : NSObject {
int _age;
} - (void)setAge:(int)age; // 方法名是setAge:
- (int)age; // 方法名是age // 方法名是setAge:andNo:
// - (void)setAge:(int)newAge andNo:(int)no;
@end

Person.m

#import "Person.h"

@implementation Person

- (void)setAge:(int)age {
NSLog(@"调用了setAge方法:%i", age);
_age = age; // 这是错误的写法,会导致死循环,无限调用set方法
// self.age = newAge;// [self setAge:newAge];
} - (int)age {
NSLog(@"调用了age方法:%i", _age); return _age;
}
@end

最新文章

  1. 第一个python实例--监控cpu
  2. PreparedStatement
  3. 关于UltraEdit的两个小问题
  4. 如何加载JS
  5. require
  6. MySQL到MsSQL的迁移工具——SSMA
  7. 云计算之路-阿里云上:遭遇CDN问题
  8. UVA5870 乱搞 Smooth Visualization
  9. mysql命令行导入sql文件
  10. 【Convert Sorted List to Binary Search Tree】cpp
  11. $(document).Ready()方法 VS OnLoad事件 VS $(window).load()方法
  12. hdu4081
  13. 20. Valid Parentheses【leetcode】
  14. Xcode中StoryBoard Reference 新特性的使用
  15. Vue.js实现注册功能
  16. sqlsever存储过程配合代理作业自动定时建表
  17. Java开发笔记(五十九)Java8之后的扩展接口
  18. Hdoj 1850.Being a Good Boy in Spring Festival 题解
  19. Realm 处理List&lt;String&gt; 问题 Type parameter &#39;java.lang.String&#39; is not within its bound; should implement &#39;io.realm.RealmModel
  20. ansible运维工具(一)

热门文章

  1. PIE SDK矢量数据编辑事件的监听
  2. 转 .net 获取IP地址的三个方法的比较
  3. RedisClient 连接redis 提示 ERR Client sent AUTH, but no password is set
  4. Maven---pom.xml 详解(转)
  5. 啊啊啊啊啊啊啊今天就写,炒鸡简单 数据库Sqlite的创建,库的增删改查
  6. 《HTTP权威指南》之HTTP连接管理及对TCP性能的考虑
  7. 【原】shell编写一个简单的jmeter自动化压测脚本
  8. OpenLayers 案例一
  9. NDK编译不同架构的参数
  10. 深入理解Javascript封装DOMContentLoaded事件