zoukankan      html  css  js  c++  java
  • 集合内存管理

    //

    //  main.m

    //  12-集合内存管理

    //

    //  Created by apple on 14-3-21.

    //  Copyright (c) 2014年 apple. All rights reserved.

    //

    #import <Foundation/Foundation.h>

    #import "Person.h"

    int main(int argc, const char * argv[])

    {

        @autoreleasepool {

            

            // retainCount 1

            Person * p  = [[Person alloc] init];

            

            //1

            NSMutableArray * array = [[NSMutableArray alloc] initWithCapacity:0];

            

            //当你把对象存入到,数组中的时候,数组会对这个对象进行一次 retain操作

            [array addObject:p];// [p retain] retaiCount 2

            

            //当你把一个对象移除数组中的时候,会对该对象进行一次 release操作 retainCount 1

    //        [array removeObject:p];

            //会对数组中所有的对象,进行一次,relsease操作

    //        [array removeAllObjects];

            

            //当集合对象被销毁的时候,会对其内部所有的对象进行一次 release操作

            //0

            [array release];

            //retainCount - 0

            

            

            //0

            [p release];

            

            NSLog(@"ddddd");

            

        }

        return 0;

    }

  • 相关阅读:
    datatime模块
    快速幂
    | 与|| ,& 与&&
    sql----order by
    pandas iterrows()
    黄包车比赛 python学习
    右键git-bash不能使用
    17flask分页
    16flask错误处理
    15跨站请求伪造
  • 原文地址:https://www.cnblogs.com/supper-Ho/p/6185778.html
Copyright © 2011-2022 走看看