OC2

it2024-11-04  13

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

 

转载于:https://www.cnblogs.com/0515offer/p/4589544.html

相关资源:数据结构—成绩单生成器
最新回复(0)