使用以下命令创建对象意味着什么:id <class> instanceName?

Woo*_*tty 4 iphone xcode objective-c

我在苹果网站上看到了一些像这样的代码

id <NSFetchedResultsSectionInfo> sectionInfo = ...
Run Code Online (Sandbox Code Playgroud)

这与以下有何不同?

NSFetchedResultsSectionInfo *sectionInfo = ...
Run Code Online (Sandbox Code Playgroud)

我对NSFetchedResultsSectionInfo本身并不那么感兴趣,而是对它的声明方式感兴趣.

谢谢你!
特里斯坦

jak*_*kev 5

NSFetchedResultsSectionInfo是一个协议.id是一种声明泛型对象的方法,并id <NSFetchedResultsSectionInfo>声明必须遵守NSFetchedResultsSectionInfo协议的通用对象.