objective c - Trying to make this work... (Xcode for mac NOT iPhone) - ArrayController -


i'm writing stopwatch application mac, , working on 'laps' feature. putting laps table view better organization. i'm using array controller put things table.

basically, i'm trying this:

[arraycontroller addobject: [nsmutabledictionary dictionarywithobjectsandkeys:@"lap 1", @"lapnumber", nil]]; 

that works fine , dandy, i'd able control number next lap using integer representing number of laps, called numlaps. thus, code be:

[arraycontroller addobject: [nsmutabledictionary dictionarywithobjectsandkeys:@"lap %i",  numlaps, @"lapnumber", nil]]; 

however, more 2 commas before nil, think program getting screwed up. getting following thrown in console, though don't understand means / how fix it:

2013-09-03 16:52:31.515 popup[3242:303] +[nsmutabledictionary dictionarywithobjectsandkeys:]: second object of each pair must non-nil.  or, did forget nil-terminate 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 ) 

any ideas how implement i'm trying in fashion won't confuse program?

thanks.

you should use modern obj-c notation. enables create dictionaries , arrays in more natural way.

nsdictionary *dic = @{@"laps ": @(numlaps), @"someotherkey":@"anditswalue"}; 

in code show keys , values not in pairs. must insert pairs. (for detailed reference see nsdictionary documentation.)

nsstring *key = @"laps"; nsstring *value = [nsstringwithformat:@"lap %i", numlaps]; [arraycontroller addobject: [nsmutabledictionary dictionarywithobjectsandkeys:         value, key, nil]]; 

also, need think on want store in dictionary. keys , values not apparent in example.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -