OC2_ARC MRC混合编程

//
//  main.m
//  OC2_ARC MRC混合编程
//
//  Created by zhangxueming on 15/6/19.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Person.h"
#import "Dog.h"

//-fno-objc-arc    BuildPhases 下的 complle Sources  (Compiler Flags)  person.m 跟 dog.m   添加 -fno-objc-arc
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        Person *xiaoHua = [[Person alloc] init];
        Dog *dog = [[Dog alloc] init];
        xiaoHua.dog = dog;
    }
    return 0;
}



//
//  Dog.h
//  OC6_复合类的类存管理
//
//  Created by zhangxueming on 15/6/18.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Dog : NSObject

@property (copy, nonatomic) NSString *name;
@property (assign,nonatomic) NSInteger age;

@end



//
//  Dog.m
//  OC6_复合类的类存管理
//
//  Created by zhangxueming on 15/6/18.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import "Dog.h"

@implementation Dog

- (void)dealloc
{
    NSLog(@"%@: dog name is release!!!", [self class]);
    [_name release];
    [super dealloc];
}

@end



//
//  Person.h
//  OC6_复合类的类存管理
//
//  Created by zhangxueming on 15/6/18.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Dog.h"

@interface Person : NSObject

@property (retain, nonatomic) Dog *dog;

@end



//
//  Person.m
//  OC6_复合类的类存管理
//
//  Created by zhangxueming on 15/6/18.
//  Copyright (c) 2015年 zhangxueming. All rights reserved.
//

#import "Person.h"

@implementation Person

- (void)dealloc
{
    NSLog(@"%@:dog is release", [self class]);
    [_dog release];
    [super dealloc];
}


@end

 

posted @ 2015-06-19 19:00  sirzhang  阅读(257)  评论(0编辑  收藏  举报
AmazingCounters.com