5

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.

And also we can use -fobjc-arc flag to enable ARC for files support ARC in a Non-ARC project.

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?

Anyone please brief me about the same.

Thanks in Advance.

Sunil Targe
  • 7,251
  • 5
  • 49
  • 80

3 Answers3

20

you need to follow this step

  1. go to your project targets - search - Objective-C Automatic Reference Counter

  2. Set NO from YES

Enjoy Progaramming!

Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34
  • yes & it is the shortest way to convert ARC into NON-ARC as questioner demanded for the same that is "if I want to convert my ARC project(not particular file) to Non-ARC project, then how should I go ahead for the same?" – Niru Mukund Shah Dec 20 '12 at 06:36
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:

MyClass *myObj = [[MyClass alloc] init];
[myObj doStuff];

OtherClass *otherObj = [[OtherClass alloc] init];
return otherObj;

should be something like this under 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.

  • I didn't downvote you, but I think they are asking about changing the project settings from ARC enabled to ARC disabled, not about converting a specific file. – Jack Humphries Dec 20 '12 at 06:36
  • @JackHumphries Thanks, I see - but that indeed assumes a specific IDE (Xcode) in this case, and that is not mentioned in the question. –  Dec 20 '12 at 06:37
  • @H2CO3 should i do this in every files of project? is not there any common way to do in single step? – Sunil Targe Dec 20 '12 at 06:44
  • @SunilTarge If your IDE (for example Xcode) supports this kind of conversion, then you don't have to do it. If, for example, you use a command-line only toolchain with no ARC-aware IDE (and text/code editor), then you have to do this manually. –  Dec 20 '12 at 06:48
1

enter image description here

very simple way edit -> covert ->to Objective-C ARC

user3540599
  • 721
  • 9
  • 6