I am wondering in Xcode, can I quickly know which classes implement some protocols?
I don't want to use search, but want to quickly identify such classes.
You can create objects from classes, whereas protocols are just type definitions. Try to think of protocols as being abstract definitions, whereas classes and structs are real things you can create.
Since classes, structures and, enums can conform to more than one protocol, they can take the default implementation of multiple protocols.
A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of those requirements.
You can limit protocol adoption to class types (and not structures or enumerations) by adding the AnyObject or class protocol to a protocol's inheritance list.
You can use the Assistant Editor:
@protocol
definitionProtocols
:The classes that implement the protocol will be in the list.
Edited to add info from Rob's comment:
Note that this only finds classes that, either in their public header or in their implementation declare that they conform to the protocol. If conformance to the protocol is declared somewhere else, those classes will not show up.
Say you have a protocol defined somewhere as
@protocol MyProtocol <NSObject>
…
@end
A class with a public header MyClass.h
like this will show up:
@interface MyClass : NSObject <MyProtocol>
Also, a class that is extended in the .m file like this will show up
@interface MyObject () <SomeProtocol>
…
@end
@implementation MyObject
…
@end
A class extension MyClass_Extension.h
like this will not show up:
@interface MyObject (Extension) <SomeProtocol>
…
@end
in particular class in which protocol implement just press 'command btn + right click of mouse' on protocol method..
it will show list of all class with implementation of this method. and you can jump on that class by just click on it...
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