• 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
  • 相关阅读:
    约数个数 和 约数之和
    二分模板
    新生赛补题
    codefores刷题心得3 思维+dp(特别好玩)
    二叉树的遍历及例题
    团队作业七——团队作业分配
    WarPlane——游戏设计文档
    团队作业(五)
    团队作业(四)
    团队项目方案分析
  • 原文地址:https://www.cnblogs.com/0515offer/p/4589544.html
Copyright © 2020-2023  润新知