• 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
Compile error: "multiple methods named '-initWithSize:' found"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Compile error: "multiple methods named '-initWithSize:' found"


  • Subject: Compile error: "multiple methods named '-initWithSize:' found"
  • From: Julian Wood <email@hidden>
  • Date: Wed, 9 Dec 2009 00:24:21 -0700

Hi,

I've been following this tutorial:

http://www.otierney.net/objective-c.html#subinheritance

which had been going well until I got to inheritance. When compiling that example, one gets a strange error that I would not have expected:

main.m: In function 'main':
main.m:7: warning: multiple methods named '-initWithSize:' found
/System/Library/Frameworks/AppKit.framework/Headers/NSImage.h:81: warning: using '-(id)initWithSize:(NSSize)aSize'
Square.h:4: warning: also found '-(Square *)initWithSize:(int)s'
main.m:7: error: incompatible type for argument 1 of 'initWithSize:'

Why would those two methods clash? NSImage is not even included. Moreover, aren't we saying specifically to use initWithSize from Square? And finally, why does it think we are not using an int as a param?

Simply changing the method name to initWithASize makes everything happy, but I feel I am missing something critical.

Can anyone explain this error? And a better way to avoid collisions of this type in the future?

Thanks,

Julian



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Compile error: "multiple methods named '-initWithSize:' found"
      • From: Bill Bumgarner <email@hidden>
  • Prev by Date: Re: Adding existing svn files to new project
  • Next by Date: Re: Compile error: "multiple methods named '-initWithSize:' found"
  • Previous by thread: Re: How to add a generated file to a project's resources
  • Next by thread: Re: Compile error: "multiple methods named '-initWithSize:' found"
  • Index(es):
    • Date
    • Thread