Reputation: 37
Hello I am completely new to Apple development I used this code in my project https://github.com/vladinecko/accordion-uitableview/tree/master/AccordionTableView , project releases the memory itself using autorelease What made me disable the ARC Because ARC does not allow the use of autorelease My question is whether to delete the autorelease from the code And use ARC or i can not do it and I need to have to release the memory for myself
Upvotes: 1
Views: 292
Reputation: 151
First, being new to Objective-C development you need to learn how memory management works. Google for "Apple memory management" and you should find relevant documents.
Before ARC, people did memory management by hand. With ARC, ARC does it for you. The exact same memory management operations should happen, except that with ARC you have less programmer work, and chances to get it right are better.
You have two choices: Either turn ARC off for individual files. This is done in Xcode / target settings / Build phases / Compile sources by adding -fno-objc-arc to the build settings for individual files where you don't want to use ARC. If you use the same files in different projects, you have to do this in every target.
The other choice is to convert the files to ARC. Let the compiler run, remove offending memory management code, which is mostly retain / release / autorelease. If the code uses CoreFoundation functions, then you really need to understand memory management, just hope it doesn't. Use "Analyze" to let the compiler check very carefully that everything is fine.
Upvotes: 0
Reputation: 9865
Apparently AccordionTableView
does not use ARC, whereas in your project you are using it.
So you have three options
AccordionTableView
AccordionTableView
project with ARC guidelinesUpvotes: 0
Reputation: 9533
You could leave the code as-is—you can compile some files using ARC and others not, but that’s going to be messy and hard to maintain.
What I’d recommend doing is running Xcode’s ARC-ifying on the code, to get rid of retain and release and autorelease.
In Xcode 5, look under the “Edit” menu for “Refactor”, and select “Convert to ObjC ARC”.
Upvotes: 4