您的位置:首页 > 其它

OC12_自动释放池

2015-06-18 20:48 232 查看
//
//  Dog.h
//  OC12_自动释放池
//
//  Created by zhangxueming on 15/6/18.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Dog : NSObject

@end

//
//  Dog.m
//  OC12_自动释放池
//
//  Created by zhangxueming on 15/6/18.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import "Dog.h"

@implementation Dog

- (void)dealloc
{
NSLog(@"dog is release");
[super dealloc];
}

@end


//
//  main.m
//  OC12_自动释放池
//
//  Created by zhangxueming on 15/6/18.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Dog.h"

int main(int argc, const char * argv[]) {
NSMutableArray *releasePool=[[NSMutableArray alloc] init];

Dog *xiaoBai = [[Dog alloc] init];
[releasePool addObject:xiaoBai];
[xiaoBai release];
NSLog(@"xiaoBai = %li", xiaoBai.retainCount);

Dog *xiaoHei = [[Dog alloc] init];
[releasePool addObject:xiaoHei];
[xiaoHei release];

[releasePool release];

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: