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
Asked
Active
Viewed 36 times
1 Answers
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
-
1Thanks 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
-
1Take 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