pragma mark MRC项目转ARC项目
pragma mark 概念
/**
MRC 转 ARC 通过 Xcode中
Edit --> Convert(转换) --> to Objective-C ARC (转换成ARC)
然后出现一个预览的界面
左边是 修改之后的代码区、
右边是 修改之前的代码区
*/
pragma mark 代码
#import <Foundation/Foundation.h>
#pragma mark 类
#import "Person.h"
#import "Dog.h"
#import "Bone.h"
#pragma mark main函数
int main(int argc, const char * argv[])
{
Person *p = [Person new];
Dog *d = [Dog new];
Bone *b = [Bone new];
return 0;
}
Person.h //人类
#import <Foundation/Foundation.h>
@class Dog;
@interface Person : NSObject
@property (nonatomic, strong) Dog *dog;
@end
Person.m
#import "Person.h"
#import "Dog.h"
@implementation Person
- (void)dealloc
{
NSLog(@"%s",__func__);
}
@end
Dog.h //狗类
#import <Foundation/Foundation.h>
@class Bone;
@interface Dog : NSObject
@property(nonatomic, retain)Bone *bone;
@end
Dog.m
#import "Dog.h"
#import "Bone.h"
@implementation Dog
- (void)dealloc
{
NSLog(@"%s",__func__);
}
@end
Person.h //骨头类
#import <Foundation/Foundation.h>
@interface Bone : NSObject
@end
Person.m
#import "Bone.h"
@implementation Bone
- (void)dealloc
{
[super dealloc];
}
@end
网友评论