views:

217

answers:

2

Hi,

do I have to call super in didTurnIntoFault? I couldn't find any directions in the documentation.

- (void)didTurnIntoFault {
  [super didTurnIntoFault]; // Do I have to call super?
  // ...
}
A: 

No, I don't believe so. The purpose of didTurnIntoFault is to give you a chance to release any instance variables (particularly for transient values) you might be holding. While it is meant to be used as a replacement for dealloc for NSManagedObject subclasses, that's because the life cycle of an NSManagedObject is quite different from an ordinary NSObject. So, although it serves much the same purpose as dealloc, it doesn't work in quite the same way.

Of course, if you subclass your own subclass of NSManagedObject, you will need to call [super didTurnIntoFault] there.

That said, I would imagine that NSManagedObject's implementation is probably a no-op, so I sincerely doubt there's any harm in invoking it anyway. Also, because there's no harm in it, it may help you to remember to call it when it really does matter.

Alex
I agree with you. The reason why I'm asking is to play it safe.
cocoafan
A: 

If you subclass NSManagedObject and override -didTurnIntoFault, you must send the message to super.

See the Subclassing Notes of the NSManagedObject class reference.

Jim Correia