I am new at programming in general (though I have had a C class many, many years ago) and am learning Objective-C for programming on the iPhone. I have what I think is a simple question, but after looking for a while (days, off and on) I can’t find the answer that I’m looking for explicitly.
I know that when subclassing an Objective-C class I should implement the initialize method along with the deallocate method (unless using ARC for the latter, if I am correct?). The questions are:
- Are these the only two to worry about, or will other classes potentially have additional methods that can be required to be implemented?
- If other classes might have methods that I am required to implement when subclassing them, where is that documentation typically found? (I don’t seem to see that in the Apple framework docs, though that kind of information is there for protocols it appears)
Thanks for your help!
initanddeallocif the inherited versions are sufficient. Also, ARC does not free you from having to writedeallocin all cases (but it certainly covers the overwhelming majority). For example, if you allocate memory for your object usingmalloc, you need to free it in thedealloc.@requried. These methods are marked in the protocol reference. For example,tableView:cellForRowAtIndexPath:andtableView:numberOfRowsInSection:are marked with the “required method” tag in Apple’s documentation.