Amazon.com Widgets Program 19.5. Why are some methods not declared in the class interface?
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 02, 2014, 03:25:44 AM
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
Print
Author Topic: Program 19.5. Why are some methods not declared in the class interface? (Read 1427 times)
pierre
Newbie
*
Posts: 32


Email




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

Page 440.
Quote
"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?
Logged
pierre
Newbie
*
Posts: 32


Email




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.
Logged
skochan
Administrator
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.

Cheers,

Steve Kochan
Logged
Pages: [1] Go Up
Print
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.