-1

Why do we need to use id type for creating delegate object for protocols in Objective C? I couldn't find proper answer from google

Kumaravel G
  • 71
  • 1
  • 5

1 Answers1

0

Because a delegate can be implemented by any type of object.
Ex : UIViewController, UIView, NSObject class can all implement the same protocol, so the delegate can't know the type, so it's set to id.

David Ansermot
  • 6,052
  • 8
  • 47
  • 82
  • 1
    Thanks for the answer. also why we are using **weak** type for **id** object instead of **strong** type? – Kumaravel G Sep 23 '14 at 11:35
  • 1
    Take a look at this answer : http://stackoverflow.com/questions/8449040/why-use-weak-pointer-for-delegation. And can you mark my answer as accepted if it's ok for you. – David Ansermot Sep 23 '14 at 11:50