0

i have a question about objective c. I bought a book about objective c. I am new in objective c and the book include many tutorials about memory management. I have the mac version 10.7.5. So in the tutorial about dealloc, xcode say me "ARC forbids explicit message send of 'dealloc'". So i search this error in many forums. In these forums many people say that [super dealloc] inherits from NSObject is old and the newer version of system make the memory management automatically. The book comes out 2011.

I hope everyone understand me.

Thank you in advance.

Yetispapa
  • 2,174
  • 2
  • 30
  • 52
  • ARC was introduced in mid-2011. Your book likely predates ARC. In any case, the compiler error is correct -- you don't need to (i.e. must not) call `[super dealloc]` in your `-dealloc` implementation. – Caleb Aug 15 '13 at 19:20

1 Answers1

3

There is a new(ish) system for iOS called ARC which automatically sends release/retain/dealloc etc. messages to your objects. You may read more about it here.

The important thing to note when answering your question is that ARC is optional. You may use it, but you do not have to. (When creating a new XCode project, you either tick the "enable automatic reference counting" button, or you don't.)

So, to answer your question: if you are using ARC in your project, yes, dealloc is no longer necessary. If you're not using ARC, you will still need to manage your own memory. It depends on how you're setting up your project.

WendiKidd
  • 4,333
  • 4
  • 33
  • 50
  • Is using ARC recommend? Should i use it for my future projects? – Yetispapa Aug 15 '13 at 19:18
  • 1
    @AlexStein if you're following a book that's not using it, you may have an easier time if you disable it. It's definitely useful to know the manual memory management rules as effectively troubleshooting ARC is aided by that understanding, so you may be well served in the future by disabling it for the moment. – Carl Veazey Aug 15 '13 at 19:28
  • -dealloc isn't "invalid". You simply do not need to release/nullify the ivars there. Since this was the only taks of -dealloc in many, many cases, you can omit it. – Amin Negm-Awad Aug 15 '13 at 19:29