2

I noticed that there is no dealloc method already placed in various class files when i create an ios5 based project, but I remember that there is a ready-made dealloc method placed in most of these files in ios 4.3 based projects ... does that mean that if I did not release allocated objects, no memory leak will happen ? or should I my own dealloc method ?

JAHelia
  • 6,934
  • 17
  • 74
  • 134

3 Answers3

3

Only if you use ARC. I guess this change is an intensive for us to do so. If you don't you should implement the dealloc as you did before.

jbat100
  • 16,757
  • 4
  • 45
  • 70
  • is there an option in XCode to enable ARC for the project ? or it needs coding ? – JAHelia Nov 02 '11 at 13:12
  • I don't see why you would want to go without ARC, is there a reason to avoid using it? – Brandon Buck Nov 02 '11 at 13:12
  • @JaHelia you need to refactor your code to be ARC compliant (Edit->Refactor->Convert To Objective-C ARC), more info here http://stackoverflow.com/questions/6448874/automatic-reference-counting-for-some-files. – jbat100 Nov 02 '11 at 13:19
3

iOS 5 contains feature called ARC, Automatic Reference Counting, http://developer.apple.com/technologies/ios5/ which means that developer is no longer responsible for manual memory management.

Bolek Tekielski
  • 1,194
  • 2
  • 10
  • 25
1

This is because iOS 5 projects,by default have ARC enabled. On an ARC enabled projects, all releases, autoreleases and deallocs are illegal.

Community
  • 1
  • 1
Vin
  • 10,517
  • 10
  • 58
  • 71
  • I have not started development on iOS 5 yet, will the compiler throw a warning? Build will fail? If you have releases? – Marc Brannan Nov 02 '11 at 15:03
  • With new projects ARC will already be enabled. For old projects which have manual memory management, you can upgrade to use ARC or just opt out from ARC. See this:http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html#//apple_ref/doc/uid/TP40011226 – Vin Nov 02 '11 at 15:16