This Java-Code works:
public void executeCommand(ICommand cmd) { // ICommand is an Interface
if (cmd.getClass().equals(LoginCommand.class)){
}
}
But this Objective-C-Code doesn't work:
- (void)executeCommand: (id<Command>)cmd { // Command is a Protocol
if ([cmd isKindOfClass:[LoginCommand class]]) {
// WARNING: '-conformsToProtocol:' not found in protocol
}
}
When you declare your protocol, tell it to inherit from the NSObject protocol like this:
@protocol Command <NSObject>
...
@end
reference is here. NSObject is a base protocol that implements -conformsToProtocol:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With