objective-c – 目标C:什么是[ClassName self];做?

前端之家收集整理的这篇文章主要介绍了objective-c – 目标C:什么是[ClassName self];做?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在查看 CocoaHTTPServer project的源代码,更具体的是HTTPServer.m文件,我只是不明白这一行:
connectionClass = [HTTPConnection self];

这是做什么的(是否记录在任何地方)?它如何编译?应该不是

connectionClass = [HTTPConnection class];

解决方法

在这个上下文中,– (id)self是一个在NSObject上定义的方法.它返回接收器.对于一个类,它应该显然与调用 – (Class)类一样.

Class objects are thus full-fledged objects that can be dynamically typed,receive messages,and inherit methods from other classes. They’re special only in that they’re created by the compiler.

原文链接:https://www.f2er.com/c/112606.html

猜你在找的C&C++相关文章