A protocol, declared with the ( @protocol syntax in Objective-C) is used to declare a set of methods that a class "adopts" (declares that it will use this protocol) will implement. This means that you can specify in your code that, "you don't care which class is used as long as it implements a particular protocol". This can be done in Objective-C as follows: id<MyProtocol> instanceOfClassThatImplementsMyProtocol; @protocol MyProtocol < NSObject > - ( void ) aRequiredMethod ; @required - ( void ) anotherRequiredMethod ; @optional - ( void ) anOptionalMethod ; @end @interface MyClass < MyProtocol > @end You usually keep reference to an object conforming to a protocol using a property. For example, to keep track of a delegate: @property ( nonatomic , weak ) id < MyProtocol > delegate ; At this point, in your code, you just have to call the method you want to call on the object that you're keeping refere...
Learn ios programming with us. Topics we will learn: Delegates design patterns Remote notification push notification MVC Mobile app development ios app development apple technology discussion singleton nsurl connection nsurl session blocks functions datatype