Can anyone tell me what the angle brackets <...>
in an Objective-C class interface do? Like this one (from http://snipt.net/robhawkes/cocoa-class-interface):
@interface MapMeViewController : UIViewController <CLLocationManagerDelegate,
MKReverseGeocoderDelegate, MKMapViewDelegate, UIAlertViewDelegate> { ... }
From my view they look like some sort of type declaration (considering my previous experience in PHP and JavaScript), like we're making sure MapMeViewController
is a CLLocationManagerDelegate
, MKReverseGeocoderDelegate
, MKMapViewDelegate
, or UIAlertViewDelegate
Documentation about the @interface
syntax don't seem to mention this.
An angle bracket or angle brace or angle cleat is an L-shaped fastener used to join two parts generally at a 90 degree angle. It is typically made of metal but it can also be made of wood or plastic. The metallic angle brackets feature holes in them for screws.
angular brackets are used for global use of the header files which are predefined and we include in our program. When you use angle brackets, the compiler searches for the file in the include path list. Angular brackets are used for standard inclusions.
The angle brackets in a class interface definition indicates the protocols that your class is conforming to.
A protocol is almost like an interface in Java or C#, with the addition that methods in an Objective-C protocol can be optional.
Additionaly in Objective-C you can declare a variable, argument or instance variable to conform to several protocols as well. Example
NSObject<NSCoding, UITableViewDelegate> *myVariable;
In this case the class must be NSObject
or a subclass (only NSProxy
and its subclasses would fail), and it must also conform to both NSCoding
and UITableViewDelegate
protocols.
In Java or C# this would only be possible by actually declaring said class.
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