7
votes

I have an Xcode 3.2 targeted project . I want to convert this project to ARC to improve the

performance.I am following these steps.

Edit->Refactor->Convert to Objective C ARC

I have got some .mm files to which I am disabling the ARC using -fno-objc-arc. But even after

this I am getting lot of errors (ARC issues). For eg mainly in self=[super init]call,the

error is cannot assign to self outside of a method in the init family. Can

anyone tell me am I following the correct steps ?

2

2 Answers

15
votes

I was trying to convert a projet to ARC and after creating a new one and including the files from the old one - one of the issues i got was

Cannot assign to 'self' outside of a method in the init family

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

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

Notice the small 'w'.

I have changed it to:

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

Notice the capital 'W'!

My problem was solved.

I hope this helps someone.

1
votes

Ray Wenderlich's tutorials have a pretty good ARC-conversion two-part tutorial which should detail the right steps to take: Part 1 Part 2

In terms of the error you're having, the description pretty much sums it up: you're assigning to self in a method which doesn't meet the standard for init methods. I can't speak for whether that's legal pre-ARC but it certainly isn't anymore. To resolve that one, either make it an init method (follows the init practise of calling a super init method into self, initialising any values, and returning self), or take out the assignment to self inside it. For other errors, post any you're having an issue with (many of them are covered in Ray's tutorials), and we'll do what we can.