As per my knowledge, I know that we use -fno-objc-arc
flag to disable ARC for files that NOT support ARC in an ARC project.
据我所知,我知道我们使用-fno-objc-arc标志为ARC项目中不支持ARC的文件禁用ARC。
And also we can use -fobjc-arc
flag to enable ARC for files support ARC in a Non-ARC project.
此外,我们还可以使用-fobjc-arc标志启用ARC,以便在非ARC项目中支持ARC文件。
But if I want to convert my ARC project(not particular file) to Non-ARC project, then how should I go ahead for the same?
但是,如果我想将我的ARC项目(非特定文件)转换为非ARC项目,那么我应该如何进行相同的操作呢?
Anyone please brief me about the same.
有人请介绍一下这个问题。
Thanks in Advance.
提前致谢。
3 个解决方案
#1
4
You have to insert manual memory management method calls in the appropriate places. In general, every new
, alloc
, retain
, copy
and mutableCopy
call shall be balanced by a release
or an autorelease
(the latter is mainly used in the case of return values), so, for example, the following ARC-enabled code:
您必须在适当的位置插入手动内存管理方法调用。通常,每个new,alloc,retain,copy和mutableCopy调用都应该通过release或autorelease来平衡(后者主要用于返回值),例如,以下启用ARC的代码:
MyClass *myObj = [[MyClass alloc] init];
[myObj doStuff];
OtherClass *otherObj = [[OtherClass alloc] init];
return otherObj;
should be something like this under MRC:
在MRC下应该是这样的:
MyClass *myObj = [[MyClass alloc] init];
[myObj doStuff];
[myObj release];
OtherClass *otherObj = [[OtherClass alloc] init];
return [otherObj autorelease];
More about memory management in the official documentation.
更多关于官方文档中的内存管理。
#2
20
you need to follow this step
你需要按照这一步
-
go to your project targets - search - Objective-C Automatic Reference Counter
转到您的项目目标 - 搜索 - Objective-C自动参考计数器
-
Set
NO
from YES从YES设置NO
Enjoy Progaramming!
#1
4
You have to insert manual memory management method calls in the appropriate places. In general, every new
, alloc
, retain
, copy
and mutableCopy
call shall be balanced by a release
or an autorelease
(the latter is mainly used in the case of return values), so, for example, the following ARC-enabled code:
您必须在适当的位置插入手动内存管理方法调用。通常,每个new,alloc,retain,copy和mutableCopy调用都应该通过release或autorelease来平衡(后者主要用于返回值),例如,以下启用ARC的代码:
MyClass *myObj = [[MyClass alloc] init];
[myObj doStuff];
OtherClass *otherObj = [[OtherClass alloc] init];
return otherObj;
should be something like this under MRC:
在MRC下应该是这样的:
MyClass *myObj = [[MyClass alloc] init];
[myObj doStuff];
[myObj release];
OtherClass *otherObj = [[OtherClass alloc] init];
return [otherObj autorelease];
More about memory management in the official documentation.
更多关于官方文档中的内存管理。
#2
20
you need to follow this step
你需要按照这一步
-
go to your project targets - search - Objective-C Automatic Reference Counter
转到您的项目目标 - 搜索 - Objective-C自动参考计数器
-
Set
NO
from YES从YES设置NO
Enjoy Progaramming!