views:

101

answers:

2

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.

A: 

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

for (CalCalendar* cal in [[CalCalendarStore defaultCalendarStore] calendars])
    [myPopUpButton addItemWithTitle:[cal title]];
Nikolai Ruhe
Good that works. Now I thought of something, the Calenders are displayed in order, meaning `objectAtIndex:0` is the first in the list and so on. Could you not use `indexOfSelectedItem` on the NSPopUpButton to get the index of the selected one and then replace the 0 for `objectAtIndex:` with its result?
Joshua
Joshua: Correct.
Peter Hosey
A: 

is there a way to get only the calendars selected (checked) in the ical and not all the calendars?

yoavs
Hi, @yoavs. This should probably be posted as a separate question, since it's out of place as an answer. You can post a new question my clicking the "Ask Question" button on the top right of this page, and you'll be able to link to this question if you need to for reference.
Bill the Lizard