OC12_자동 방출 탱크

3804 단어 oc
//

//  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;

}

좋은 웹페이지 즐겨찾기