//
// 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的更多相关文章

随机推荐

  1. PC/UVa 题号: 110104/706 LC-Display (液晶显示屏)题解

    #include <string> #include <iostream> #include <cstring> #include <algorithm> ...

  2. C语言用static限制函数以及全局变量的作用域

    今天才发现这个东西! C语言中没有public private之类的东西. 如果一个函数或者一个全局变量只想在一个.c文件中使用,可以在前面加上static! 以前我还傻傻的每个.c文件中的函数都加一 ...

  3. Web之真假分页

    在web设计中一个无法避免的问题就是分页显示.当数据量特别大的时候,我们不可能将全部的数据都在一个页面进行显示,假设这样将严重影响到它的美观性.所以在这个时候,分页显示则成为了我们的大功臣.当然分页也 ...

  4. Activity生命周期解说

    前言: 一直想着写一些Android基础知识分享给大家.可是有时候又认为怕写不好误导了大家学习Android.思前想后认为还是去Android官网看看,发如今Android官网上事实上就能学习到非常多 ...

  5. 错误解决:release' is unavailable: not available in automatic reference counting mode

    解决办法: You need to turn off Automatic Reference Counting. You do this by clicking on your project in ...

  6. 用 UIViewPropertyAnimator 编写动画

    [iOS 10 day by day] Day 1:开发 iMessage 的第三方插件 [iOS 10 day by day] Day 2:线程竞态检测工具 Thread Sanitizer < ...

  7. hdfs: 一个分布式文件系统(一)

    一. hdfs设计的动机 为大规模分布式计算准备的分布式文件系统,并非实时性要求很高的文件系统. 二. 设计的取舍 1. 因为要求有高吞吐量,所以牺牲读取文件的实时性,实时性要求高的分布式文件系统可以 ...

  8. Android(java)学习笔记114:LayoutInflater和findViewById

    1. 在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById(). 不同点是LayoutInflater是用来找res/layout/下的xml布局文件, ...

  9. (转载)Java NIO:NIO概述(一)

    Java NIO:NIO概述 在上一篇博文中讲述了几种IO模型,现在我们开始进入Java NIO编程主题.NIO是Java 4里面提供的新的API,目的是用来解决传统IO的问题.本文下面分别从Java ...

  10. poj 2987 最大闭合子图

    思路: 这题考的是最大闭权图.只要知道怎么求最大闭权图就知道怎么做.但好像有点卡模版,要高效的模版才行. #include <iostream> #include <stdio.h& ...