• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Typeing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Typeing
      • From: David Remahl <email@hidden>
  • Prev by Date: Re: Library loading policy on Mac OS X with Cocoa
  • Next by Date: Drag and drop problems!
  • Previous by thread: Strange problem with lots of NSGregorianDates
  • Next by thread: Re: Typeing
  • Index(es):
    • Date
    • Thread