- 不要等到明天,明天太遥远,今天就行动。
须读:看完该文章你能做什么?
如何将一个MRC的项目 转成 ARC
学习前:你必须会什么?(在这里我已经默认你具备C语言的基础了)
什么是ARC,什么是MRC
一、本章笔记
MRC 转 ARC 项目
1.> Edit -> Convert -> To Objective-C ARC
二、code
main.m
#pragma mark 07-ARCתMRC
#pragma mark 概念
/*
MRC 转 ARC 项目
1.> Edit -> Convert -> To Objective-C 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 alloc]init];
Dog *d = [[Dog alloc]init];
Bone *b = [[Bone alloc]init];
return 0;
}
Person
>>>.h
#import <Foundation/Foundation.h>
@class Dog;
@interface Person : NSObject
@property (nonatomic, strong) Dog *dog;
@end
>>>.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, strong)Bone *bone;
@end
>>>.m
#import "Dog.h"
#import "Bone.h"
@implementation Dog
- (void)dealloc
{
NSLog(@"%s",__func__);
// Receiver type 'Bone' for instance message is a forward declaration
}
@end
Bone
>>>.h
#import <Foundation/Foundation.h>
@interface Bone : NSObject
@end
>>>.m
#import "Bone.h"
@implementation Bone
- (void)dealloc
{
NSLog(@"%s",__func__);
}
@end
1.MRC转ARC流程图
2.出现错误的情况
2.1定位到错误
缺少导入头文件
3.没有错误