本帖最后由 oucding 于 2015-4-14 23:53 编辑
/*********Person对象********/
#import <Foundation/Foundation.h>
@interface Person : NSObject
@property (nonatomic, assign)int age; // 年龄
@end
@implementation Person
// 重写dealloc方法
- (void)dealloc{
NSLog(@"%ld", [self retainCount]);
NSLog(@"年龄为%d的Person对象被回收", _age);
[super dealloc];
}
@end
int main() {
@autoreleasepool {
Person *p = [[[Person alloc] init] autorelease];
p.age = 25;
}
return 0;
}
为啥程序运行的结果是: |
|