Re: Typeing
Re: Typeing
- Subject: Re: Typeing
- From: Christian Brunschen <email@hidden>
- Date: Wed, 27 Jun 2001 11:42:13 +0200 (MEST)
On Wed, 27 Jun 2001, David Remahl wrote:
>
I have the following statement:
>
>
NSEnumerator* enum = [[[NSApp delegate] arrayOfObjects]
>
objectEnumerator];
>
>
I know that my application delegate responds to arrayOfObjects, but the
>
compiler doesn't [know what object is my app delegate], so it gives me
>
this warning:
>
>
warning: cannot find method
>
warning: return type for 'arrayOfObjects' defaults to id
Actually, the compiler is complaining _not_ about the fact that it can't
be sure the application's delegate responds to '-arrayOfObjects', but
about the fact that it does not know how the '-arrayOfObjects' method is
declared! Hence, it cannot find out what the return type from [foo
arrayOfObjects] is supposed to be, so it gives the warning.
>
The code doesn't break, since id is fine for this purpose, but the
>
warnings are annoying and hide the real warnings...
It is legal to send _any_ message to an 'id', so the compiler will never
complain about that, and indeed that is not your problem here :)
>
So, how do I statically type [NSApp delegate] so that the compiler
>
understands what I am trying to do?
No need for static typing - you need to let the compiler know the
declaration for the '-arrayOfObjects' method. Probably easiest by
including the header file for the class of your application delegate.
>
/ david
// Christian Brunschen