Are selectors in Objective-C just another way to send a message to an object?
问题 Are selectors in Objective-C just another way to send a message to an object? I really don't understand why or how to use them. 回答1: They aren’t another way to send a message to an object, they’re the only way. For example, in [myView setValue:@"foo"] , setValue: is a selector. (Another, less convenient way of writing the same thing is objc_msgSend(myView, @selector(setValue:), @"foo") .) As Ian Henry says, you can use SEL values to choose a selector at runtime instead of compile time. This