Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!ames!lll-winken!uunet!hsi!stpstn!andyn From: andyn@stpstn.UUCP (Andy Novobilski) Newsgroups: comp.sys.next Subject: Re: Deferred methods and strong typing Message-ID: <3312@stpstn.UUCP> Date: 6 Jul 89 18:48:42 GMT References: <130007@gore.com> Reply-To: andyn@stepstone.com (Andy Novobilski) Organization: The Stepstone Corporation, Sandy Hook, CT Lines: 50 From the article with Jacob Gore's question about the "multiple declarations for method `someMethod`" warning, consider the two .h interface files: A.h #import ... @interface A : Object .. -(A *)someMethod; @end B.h #import "A.h" @interface B : A ... -(B *)someMethod; @end Then usage in C.m #import "B.h" ... [anInstanceOfB someMethod]; One piece of information missing is the declaration of 'anInstanceOfB'. The warning will be given by the compiler if 'anInstanceOfB' is declared type 'id'. This is because the compiler sees both interface files and the fact the programmer has deferred binding until runtime (type id). The compiler then choses the first interface as the default (notice the order of @interface statements based on "#import" ordering). Correct type information can be given to the compiler by: 1) Typing the method: [(B *)anInstanceOfB someMethod]; 2) Declaring anInstanceOfB to be type B: B *anInstanceOfB; Hope this helps. Andy Novobilski andyn@stepstone.com The Stepstone Corp. (The Objective-C People) 75 Glen Rd. Sandy Hook, CT 06770 (203)426-1875