Objective-c – Making a NSPopUpButton display all the iCal Calendars.

cocoaobjective c

I have a NSPopUpButton and I want the Menu Items in it to display the users iCal calenders.
From there I want it depending on which is selected to change this code.

CalCalendar *calendar = [[store calendars] objectAtIndex:0];

The code defines which iCal calender to sync to, at the moment it's the default calender, however I want to change the calender to sync to depending on the Calender selected in the PopUp.

My Question : How do I make the NSPopUpButton display all the users iCal calenders and depending on which one is selected to change the calender to sync to? I'm currently just using the code above which sets it to the default one.

Best Answer

This fills an empty NSPopUpButton with the names of all iCal calendars:

for (CalCalendar* cal in [[CalCalendarStore defaultCalendarStore] calendars])
    [myPopUpButton addItemWithTitle:[cal title]];
Related Topic