• 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 when protocol not implemented?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

compile error when protocol not implemented?


  • Subject: compile error when protocol not implemented?
  • From: Rua Haszard Morris <email@hidden>
  • Date: Thu, 14 Aug 2008 12:39:30 +1200

I'd like to get an error, not just a warning, when I pass an instance of a class to a method that takes a parameter conforming to some protocol, and the passed object does not implement the protocol. Is this possible? Is there a good way to set things up so an error is generated.. or is there some dynamism reason why a warning is more suited?

e.g. for this code

@protocol MyProtocol
//...
@end

// (some class)
-(void)doSomethingWithProtocol:(id <MyProtocol>)proto;

@interface BobClientClass : NSObject // does not even attempt to implement MyProtocol!

@end

// some code somewhere where I want an error
BobClientClass* bob;
[someClass doSomethingWithProtocol:bob]; // generates warning

instead of this warning

warning: class 'BobClientClass' does not implement the 'MyProtocol' protocol'

get an error something like

error: class 'BobClientClass' does not implement the 'MyProtocol' protocol'

thanks
Rua HM.
_______________________________________________

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: compile error when protocol not implemented?
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: Re: Accessing memory of another application?
  • Next by Date: @property and @synthesize not working
  • Previous by thread: Re: try this for fadebackin
  • Next by thread: Re: compile error when protocol not implemented?
  • Index(es):
    • Date
    • Thread