ios - Can Only add one object to NSMutableDictionary -


i have datepicker , uibarbuttonitem, when uibarbuttonitem pressed invokes method add selected date nsmutabledictionary. code shown below:

diarydatearr = [[nsarray alloc] initwithobjects:diarydate, nil]; nsstring *datekeystr = [nsstring stringwithformat:@"datekey%d", dicdates.count+1]; diarykeystrarr = [[nsarray alloc] initwithobjects:datekeystr, nil]; dicdates = [[nsmutabledictionary alloc] initwithobjects:diarydatearr forkeys:diarykeystrarr]; nsarray * allkeys = [dicdates allkeys]; for(nsstring *key in [dicdates allkeys]) { nslog(@"%@",[dicdates objectforkey:key]);} nslog(@"count : %d", [allkeys count]); 

however, seemingly works until count how many keys within nsmutabledictionary , count returned 1, if click button twice of 2 different dates should theoretically (or @ least how to) should add date selected in date picker making count 2. never changes 1

how objects , keys not being placed dictionary?

regards

count returning number of entries in dictionary - one. can access doing: [dicdates valueforkey:diarykeystrarr];

if click button second time, dictionary being set new one. try perhaps:

if (!dicdates) {     dicdates = [[nsmutabledictionary alloc] initwithobjects:diarydatearr forkeys:diarykeystrarr]; } else {     dicdates[datekeystr] = diarydatearr; } 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -