compile error when protocol not implemented?
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