//
// SELTest.h
// OCStudy
//
// Created by LiuMingchuan on 15/9/25.
// Copyright © 2015年 LMC. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SELTest : NSObject
@property int age;
- (void)test001:(NSString *)str;
@end
//
// SELTest.m
// OCStudy
//
// Created by LiuMingchuan on 15/9/25.
// Copyright © 2015年 LMC. All rights reserved.
//
#import "SELTest.h"
@implementation SELTest
@synthesize age;
- (void)test001:(NSString *)str {
NSLog(@"Function :%@ outPut:%@", NSStringFromSelector(_cmd),str);
}
- (void)dealloc{
NSLog(@"对象已经释放");
//必须在最后
[super dealloc];
}
@end
SELTest *test = [[SELTest alloc]init];//指针计数为1
[test retain];//指针计数加1
NSLog(@"count %ld",[test retainCount]);
[test release];
[test release];
test.age = 26;//作为下边僵尸对象检测点的说明
test = nil;//设置为nil 避免野指针
[test release];//如果没有上面的指针地址清空,执行到这句话时会出错(EXC_BAD_ACCESS)
2015-09-26 03:50:24.525 OCStudy[4939:2871217] count 2
2015-09-26 03:50:24.527 OCStudy[4939:2871217] 对象已经释放
但是开启僵尸对象检测的话,会报错
错误信息如下: