我有一个 NSComboBox,我正在尝试让它在用户选择名称时自动输入其他信息(费率、费率类型和国籍)。它有时有效,但在其他时候会导致错误。
这段代码:
- (void)controlTextDidEndEditing:(NSNotification *)aNotification{
NSInteger index = [_nameBox indexOfItemWithObjectValue:[_nameBox stringValue]];
_lblRate.stringValue =[[contents objectAtIndex:index] objectForKey:@"Rate"];
NSInteger rateType =[[[contents objectAtIndex:index] objectForKey:@"RateType"] integerValue];
[_rateTypeSwitcher setSelected:YES forSegment:rateType];
[_nationalityMenu selectItemWithTitle:[[contents objectAtIndex:index] objectForKey:@"Nationality"]];
}
导致此错误:
Ignoring exception raised in void run_cocoa_block(void *): *** -[__NSArrayM objectAtIndex:]:
index 9223372036854775807 beyond bounds [0 .. 1]