• 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
[Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning


  • Subject: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning
  • From: "Oleg Krupnov" <email@hidden>
  • Date: Tue, 14 Oct 2008 11:43:35 +0300

In my project I have two different, totally unrelated classes.

@interface ClassA : NSObject{}

-(id)initWithContext:(ContextA*)context;

@end


@interface ClassB : NSObject{}

-(id)initWithContext:(ContextB*)context;

@end

The problem is that when I call

ContextA* context = ...;
[[ClassA alloc] initWithContext:context];

Not in all cases, but in some I get the warning that the var "context"
is of different type (ContextA) than expected (ContextB). It seems
like the compiler erroneously resolves this call to ClassB instead of
ClassA, I guess because the two methods have the same name. This
problem disappears if I rename one of the methods to
"initWithContext2".

I'd like to keep the same name and I hate the compiler warning. Is
there any resolution? Is it really a bug of the Obj-C compiler?
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning
      • From: "Chris Suter" <email@hidden>
  • Prev by Date: Re: intercepting NSBrowser multiple selection extension with shift down/up arrow
  • Next by Date: Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning
  • Previous by thread: Re: how to create a faceless background application
  • Next by thread: Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning
  • Index(es):
    • Date
    • Thread