Welcome, Guest. Please login or register.
Did you miss your activation email?
April 30, 2017, 03:31:49 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Chapter Study
| | |-+ Chapter 19 - Archiving
| | | |-+ Program 19.5. Why are some methods not declared in the class interface?
Pages: [1] Go Down
Author Topic: Program 19.5. Why are some methods not declared in the class interface? (Read 2123 times)
Posts: 32

on: July 12, 2010, 05:53:31 AM

Page 440.
"For our address book example, you'd have to add these methods (encodeWithEncoder: and initWithCoder:) to both the AddressBook and AddressCard classes."
Therefore these methods belong respectively to the AddressBook and AddressCard classes. In program19.5 they are defined in the implementation section of the class AddressCard but not in the interface section. Is it not mandatory to declare all methods of a class in the interface section? This is obviously not the case for this example. Why?
Posts: 32

Reply #1 on: July 19, 2010, 11:41:47 AM

I now realize that when class A overrides an inherited method, it does not have to declare this method in the class interface.
Also if a A declares that it conforms to a protocol, it does not have to declare the methods required for that protocol.

Probably this is why the encodeWithEncoder: and initWithCoder: methods not declared in the AddressBook and AddressCard class interfaces.
Hero Member
Posts: 3114

Reply #2 on: July 22, 2010, 05:10:25 PM

Yes, that's true for inherited methods and methods defined in a protocol: they don't need to be declared in the interface section.


Steve Kochan
Pages: [1] Go Up
Jump to:

Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.