zoukankan      html  css  js  c++  java
  • OC12_自动释放池

    //
    //  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;
    }
  • 相关阅读:
    C#结构
    R语言快速入门
    C#_枚举类型
    C#_数组
    C#传递参数
    C#_字符串的操作
    python-函数之命名空间作用域
    python-迭代器和生成器
    python-文件操作
    python
  • 原文地址:https://www.cnblogs.com/0515offer/p/4586984.html
Copyright © 2011-2022 走看看