Comparing two strings through a selector: unexpected result
问题 I am doing an exercise to learn how to use selectors in Objective-C. In this code I am trying to compare two strings: int main (int argc, const char * argv[]) { @autoreleasepool { SEL selector= @selector(caseInsensitiveCompare:); NSString* str1=@"hello"; NSString* str2=@"hello"; id result=[str1 performSelector: selector withObject: str2]; NSLog(@"%d",[result boolValue]); } return 0; } But it prints zero.Why? Edit: And if I change str2 to @"hell" I get an EXC_BAD_ACCESS. 回答1: The documentation