zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    模-数(A/D)转换器
    数-模(D/A)转换器
    VIM 常用命令
    Linux常用命令
    一个开关电源传导、辐射处理案例-----Layout环路
    解决:PADS导入.DXF结构图出现坐标超出范围问题
    Python3-threading模块-多线程
    Python3-socketserver模块-网络服务器框架
    Python3-socket模块-低级网络接口
    Python3-面向对象
  • 原文地址:https://www.cnblogs.com/0515offer/p/4589544.html
Copyright © 2011-2022 走看看