我有一个字符串dummyString
需要与 100 进行比较。这是我的代码
dummyString = [prefs objectForKey:@"displaySize"];
[self setDisplaySize:dummyString];
NSLog(@"Getting ready to set display controller with value %@", dummyString);
NSLog(@"Tried 1");
if ([dummyString isEqual: @"5"]) {
NSLog(@"Loaded preferences, display Small");
displayChanged.selectedSegment = 0;}
NSLog(@"Tried 2");
if ([dummyString isEqual: @"40"]){
NSLog(@"Loaded preferences, display is Med!");
displayChanged.selectedSegment = 1;}
NSLog(@"Tried 3");
if ([dummyString isEqualToString:@"100"]){
NSLog(@"Loaded preferences, display LARGE");
displayChanged.selectedSegment = 2;}
NSLog(@"Completed trying to get display controller with value %@", dummyString);
这是 NSLog
2013-03-26 17:22:49.101 CopyBot[1011:303] Getting ready to set display controller with value 100
2013-03-26 17:22:49.102 CopyBot[1011:303] Tried 1
2013-03-26 17:22:49.102 CopyBot[1011:303] Tried 2
2013-03-26 17:22:49.102 CopyBot[1011:303] Tried 3
2013-03-26 17:22:49.103 CopyBot[1011:303] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x64c7
2013-03-26 17:22:49.103 CopyBot[1011:303] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x64c7
我尝试了几种声明不同字符串的变体,但似乎永远无法让它进入'if'语句以进行isEqual或isEqualToString的任何比较。任何帮助表示赞赏。