我正在为 mac 编写秒表应用程序,目前正在研究“圈数”功能。为了更好地组织,我将圈数放入表格视图中。我正在使用数组控制器将东西放入表中。
基本上,我想做的是:
[arrayController addObject: [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Lap 1",
@"lapNumber", nil]];
这很好用,但我希望能够使用一个表示圈数的整数(称为 numLaps)来控制圈数旁边的数字。因此,我的代码将是:
[arrayController addObject: [NSMutableDictionary dictionaryWithObjectsAndKeys:@"Lap %i",
numLaps, @"lapNumber", nil]];
但是,由于在 nil 之前有两个以上的逗号,我认为程序被搞砸了。我在控制台中收到以下内容,尽管我不完全理解它的含义/如何修复它:
2013-09-03 16:52:31.515 Popup[3242:303] +[NSMutableDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil. Or, did you forget to nil-terminate your parameter list?
2013-09-03 16:52:31.519 Popup[3242:303] (
0 CoreFoundation 0x00007fff9800a0a6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff9920b3f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff97fe8e31 +[NSDictionary dictionaryWithObjectsAndKeys:] + 433
3 Popup 0x00000001000035a0 -[PanelController btnLapWasClicked:] + 192
4 AppKit 0x00007fff96082a59 -[NSApplication sendAction:to:from:] + 342
5 AppKit 0x00007fff960828b7 -[NSControl sendAction:to:] + 85
6 AppKit 0x00007fff960827eb -[NSCell _sendActionFrom:] + 138
7 AppKit 0x00007fff96080cd3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
8 AppKit 0x00007fff96080521 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
9 AppKit 0x00007fff9607fc9c -[NSControl mouseDown:] + 820
10 AppKit 0x00007fff9607760e -[NSWindow sendEvent:] + 6853
11 AppKit 0x00007fff96073744 -[NSApplication sendEvent:] + 5761
12 AppKit 0x00007fff95f892fa -[NSApplication run] + 636
13 AppKit 0x00007fff95f2dcb6 NSApplicationMain + 869
14 Popup 0x0000000100001652 main + 34
15 Popup 0x0000000100001624 start + 52
)
任何想法如何以不会混淆程序的另一种方式实现我正在尝试做的事情?
谢谢。