Thursday, 9 June 2016

Android Interface As iOS delegation

Delegate is a pattern to make communication between two objects.In the same way we use interface in Android to create communication between two objects


In iOS Delegation is a common way of organising certain aspects of the Objective-C code for an iOS app. "delegate is an object that acts on behalf of, or in coordination with, another object when that object encounters an event in a program."


Most useful scenario of using Interface/Delegation is when we call web-service and we need to push result to controller class. 

  • We can callback method through Interface in Android as we create in objective c with delegate.

So hear is an example of Android code to call web-service and give response to its controller class.

Structure - 
  • Controller 
  • Webservice 
  • Parser 
  • Interface 
  • Module 



No comments:

Post a Comment