Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我向目标对象发送消息,但这是目标对象不知道如何响应的消息(没有定义),发生这种情况后是否会调用任何方法?在 Ruby 中,有一个 method_missing 方法。在 Objective-C 中是什么,有什么等价的吗?
正如 Richard J. Ross III 所说,您应该使用 -(BOOL)respondsToSelector:(SEL)aSelector 来查看对象是否响应它。答案是否定的,objective-c 中没有这种东西
这会引发 NSException。无法识别的选择器发送到实例等等。