我一直在看到一些类似于以下内容的代码:
@protocol MyProtocol <NSObject>
// write some methods.
@end
Run Code Online (Sandbox Code Playgroud)
MyProtocol符合NSObject协议有什么特别的原因吗?如果你做的事情如下:
id <MyProtocol> foo; // foo here conforms to NSObject AND MyProtocol?
Run Code Online (Sandbox Code Playgroud)
只是好奇逻辑是什么.
有没有一种快速的方法在Objective-C中使用某种类型的typeof()?在Javascript中我可以输入:
var a = "imastring";
console.log(typeof(a));
// --> "string"
Run Code Online (Sandbox Code Playgroud)
我想在Objective-C中清理一些不是编译器指令的东西.