Convert a project without ARC to ARC

I have a target Xcode 3.2 project. I want to convert this project to ARC to improve

. I follow these steps.

Edit-> Refactor-> Convert to Objective C ARC

I have .mm files in which I will disable ARC using -fno-objc-arc. But even after

This I get a lot of errors (problems with ARC). For example, mainly in a call to self = [super init],

the error cannot be assigned independently outside the method in the init family. Can

Will someone tell me that I am following the right steps?

+7
source share
2 answers

I tried to convert the project to ARC, and after creating a new one and including files from the old one, one of the problems I received was

Cannot assign self outside of method in init family

The name of the selector MUST begin with init - not only that - in my case, the initialization selector was:

 -(id)initwithPage:(unsigned)pageNum {...} 

Pay attention to the little 'w'.

I changed it to:

 -(id)initwithPage:(unsigned)pageNum {...} 

Pay attention to the capital "W"!

My problem is resolved.

I hope this helps someone.

+15
source

Ray Wenderlich tutorials have a pretty good ARC conversion tutorial that should show the right steps: Part 1 Part 2

In terms of the error you have, the description pretty much sums it up: you assign self in a method that does not conform to the standard for init methods . I can’t talk about whether this is legal before the ARC, but this is certainly not the case. To solve this problem, make it an init method (follow the init practice by calling the super-init method on yourself, initializing any values ​​and returning self) or unload the assignment to yourself inside. For other bugs, post any question you come across (many of which are covered in Ray tutorials) and we will do our best.

+1
source

All Articles