我正在尝试测试某些 NSTextField 中的更改。
我正在使用:
- (void)controlTextDidEndEditing:(NSNotification *)notification {
if ([notification object] == field1)
NSLog(@"field1: stringValue == %@", [field1 stringValue]);
if ([notification object] == field2)
NSLog(@"field2: stringValue == %@", [field2 stringValue]);
if ([notification object] == field3)
NSLog(@"field3: stringValue == %@", [field3 stringValue]);
}
这可行,但我想知道是否有更好的方法。谢谢
最佳答案
这很好。
field1
等我希望成为销售点。
您可以做得更好:
- (void)controlTextDidEndEditing:(NSNotification *)notification {
if ([notification object] == field1)
NSLog(@"field1: stringValue == %@", [field1 stringValue]);
else if ([notification object] == field2)
NSLog(@"field2: stringValue == %@", [field2 stringValue]);
else if ([notification object] == field3)
NSLog(@"field3: stringValue == %@", [field3 stringValue]);
}
关于objective-c - OSX Cocoa - 如何测试多个 NSTextField 中的更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16881758/