OC3_dealloc
//
// Dog.h
// OC3_dealloc
//
// Created by zhangxueming on 15/6/18.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <Foundation/Foundation.h> @interface Dog : NSObject @end //
// Dog.m
// OC3_dealloc
//
// Created by zhangxueming on 15/6/18.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "Dog.h" @implementation Dog - (void)dealloc
{
NSLog(@"dog release!!!");
[super dealloc];
} @end
//
// main.m
// OC3_dealloc
//
// 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[]) {
@autoreleasepool {
Dog *xiaoHei = [[Dog alloc] init];
Dog *xiaoBai = [xiaoHei retain];
NSLog(@"retainCount = %li", xiaoBai.retainCount);
Dog *xiaoHui = [xiaoHei retain];
NSLog(@"retainCount = %li", xiaoHui.retainCount);
[xiaoHei release];
NSLog(@"retainCount = %li", xiaoBai.retainCount);
[xiaoBai release];
NSLog(@"retainCount = %li", xiaoHui.retainCount); //最后一次release 的时候,retainCount理论值为的0, 自动调用dealloc方法释放对象
[xiaoHui release]; }
return ;
}
OC3_dealloc的更多相关文章
随机推荐
- Codeforces Round #332 (Div. 2) C. Day at the Beach 线段树
C. Day at the Beach Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599/p ...
- 2015 NOIP day2 t2 信息传递 tarjan
信息传递 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.luogu.org/problem/show?pid=2661 Descrip ...
- Codeforces Gym 100571A A. Cursed Query 离线
A. Cursed QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100571/problem ...
- HashMap解决hash冲突的方法
HashMap 采用一种所谓的“Hash 算法”来决定每个元素的存储位置.当程序执行 map.put(String,Obect)方法 时,系统将调用String的 hashCode() 方法得到其 h ...
- iOS开发——实用篇Swift篇&项目开发常用实用技术
项目开发常用实用技术 实现拨打电话 要实现打电话功能,最简单最直接的方式便是:直接跳到拨号界面 (注意:这个需要真机调试,模拟器无效果) UIApplication.sharedApplica ...
- pager 命令
https://www.percona.com/blog/2013/01/21/fun-with-the-mysql-pager-command/ Last time I wrote about a ...
- 1085. Perfect Sequence (25)
the problem is from PAT,which website is http://pat.zju.edu.cn/contests/pat-a-practise/1085 At first ...
- QTP自学攻略
QTP自学攻略 自学总是很痛苦的,看大量的书籍,可是学到的东西却不是那么实用,下面整理了一些在QTP中经常需要的函数,以及方法很实用! QTP常用函数 1, 获取对话框相应的文字: GetVisi ...
- 小白日记34:kali渗透测试之Web渗透-扫描工具-Burpsuite(二)
扫描工具-Burpsuite 公共模块 0.Spider 爬网 手动爬网 先禁用截断功能 手动将页面中点击所有连接,对提交数据的地方,都进行提交[无论内容] 自动爬网[参数设置] 指定爬网路径,否则其 ...
- 谈KVC、KVO(重点观察者模式)机制编程
一不小心,小明在<跟着贝尔去冒险>这个真人秀节目中看到了“一日警察,一世警察”的Laughing哥,整个节目除了贝尔吃牛睾丸都不用刀叉的不雅餐饮文化外,还是镜头少普通话跟小明一样烂的Lau ...