This java code works:
public void executeCommand(ICommand cmd) { // ICommand is an Interface if (cmd.getClass().equals(LoginCommand.class)){ } }
But this Objective-C-Code does not 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
link here . NSObject is a basic protocol that implements -conformsToProtocol:
-conformsToProtocol: