我有一个问题:如果我想通过标签号获取 NSTextField 的值,我该怎么办?
我动态创建 NSTextField 并通过以下代码为其设置标签:
for(int i=0; i<number;i++)
{
NSTextField *ssid = [[NSTextField alloc] initWithFrame:NSMakeRect (10,label_Y,150,25)];
[ssid setStringValue:[NSString stringWithFormat:@"SSID %d :",i +1]];
[ssid setSelectable:NO];
ssid.tag = i;
[ssid setEditable:NO];
[ssid setBordered:NO];
[ssid setDrawsBackground:NO];
[ssid setAutoresizingMask:NSViewWidthSizable];
[contentView addSubview:ssid];
label_Y -=30;
[ssid release];
NSTextField *ssid2 = [[NSTextField alloc] initWithFrame:NSMakeRect (10,label_Y,150,25)];
[ssid2 setStringValue:[NSString stringWithFormat:@"SSID %d :",i +1]];
[ssid2 setSelectable:NO];
ssid2.tag = i;
[ssid2 setEditable:NO];
[ssid2 setBordered:NO];
[ssid2 setDrawsBackground:NO];
[ssid2 setAutoresizingMask:NSViewWidthSizable];
[contentView addSubview:ssid2];
label_Y -=30;
[ssid2 release];
}
然后我想获取每个 NSTextField 的值但我不知道如何通过标签号获取 NStextfield 的值?谢谢