我正在为 MacOSX 开发一个应用程序,并且正在创建一个 NSMatrix(单选按钮),如下所示:
arrayClasifCuentas = [[NSMutableArray alloc]init];
[arrayClasifCuentas addObject:@{@"tag": @"7",@"value": @"Seven"}];
[arrayClasifCuentas addObject:@{@"tag": @"8",@"value": @"Eight"}];
[arrayClasifCuentas addObject:@{@"tag": @"9",@"value": @"Nine"}];
NSButtonCell *prototype = [[NSButtonCell alloc] init];
[prototype setTitle:@"Radio"];
[prototype setButtonType:NSRadioButton];
NSRect matrixRect = NSMakeRect(20, 20, 125, 80);
myMatrix = [[NSMatrix alloc] initWithFrame:matrixRect
mode:NSRadioModeMatrix
prototype:(NSCell *)prototype
numberOfRows:[arrayClasifCuentas count]
numberOfColumns:1];
NSArray *cellArray = [myMatrix cells];
for (int i = 0; i < [arrayClasifCuentas count]; i++) {
[[cellArray objectAtIndex:i] setTitle:[[arrayClasifCuentas objectAtIndex:i] objectForKey:@"value"]];
[[cellArray objectAtIndex:i] setTag: [[[arrayClasifCuentas objectAtIndex:i] objectForKey:@"tag"]intValue ]];
}
我接下来要做的是以编程方式选择选项七,但基于其自己的标签(7)如何做到这一点???