What does id<…> mean in Objective-C?

后端 未结 5 1640
太阳男子
太阳男子 2021-01-03 22:48

I\'m trying to use Google Analytics in an iOS application, and I saw this portion of code :

id tracker = [[GAI sharedInstance] defaultTrack         


        
5条回答
  •  甜味超标
    2021-01-03 23:19

    When you use "id" it's like void *, you know it's a pointer but you don't know the type. When you use you mean the object does implement MyProtocol. You don't know the type of the object, it can NSObject, UIViewController, you don't care. You just want the object to implement a set of protocol. Finally, GAITracker means the type of the object is GAITracker.

提交回复
热议问题