Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
December 15, 2017, 01:01:34 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: Program 19.5. Why are some methods not declared in the class interface?  (Read 2186 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:  

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 ゥ 2009 classroomM.com. All rights reserved.