Database Reference
In-Depth Information
-primitiveValueForKey:
-setPrimitiveValue:forKey:
-isEqual:
-hash
-superclass
-class
-self
-zone
-isProxy:
-isKindOfClass:
-isMemberOfClass:
-conformsToProtocol:
-respondsToSelector:
-retain
-release
-autorelease
-retainCount
-managedObjectContext
-entity
-objectID
-isInserted
-isUpdated
-isDeleted
-isFault
-alloc
-allocWithZone:
+new
+instancesRespondToSelector:
+instanceMethodForSelector:
-methodForSelector:
-methodSignatureForSelector:
Table 1—Methods never to override
-isSubclassOfClass:
to override the -init methods, I recommend strongly against it. The -awakeFromIn-
sert and -awakeFromFetch methods provide sufficient access that overriding -init
is unnecessary. (Both -awakeFromInsert and -awakeFromFetch are discussed in more
depth later in this chapter.)
KVO Methods
I'd also add all of the KVO methods. The documentation flags these methods
as “discouraged,” but I'd put them right in the “do not subclass” list. There
is no reason to override these methods, and any logic that you would want
to put into them can probably be put somewhere else with fewer issues.
-description
In addition, there's the -description method, used fairly often in logging. It is a
great way to dump the contents of an object out to the logs during debugging.
However, when we are dealing with faults (discussed in Chapter 4, Performance
Tuning , on page 61 ), we do not want to fire a fault in the -description method.
Since the default implementation of -description does the right thing with regard
to faults, it is best that we not try to override its behavior.
-dealloc
-dealloc is normally the place that we release memory before the object is being
freed. However, when we are dealing with NSManagedObject objects, it is possible
that the object will not actually be released from memory when we think it
will. In fact, the -dealloc method may never get called in the life cycle of our
application! Instead of releasing objects in the -dealloc method, I recommend
using -didTurnIntoFault as the point of releasing transient resources. -didTurnIntoFault
 
 
Search WWH ::




Custom Search