2011-06-15 38 views
0

我有一個應用程序,程序節省了EKEvent到你的iOS日曆。而不是它轉到默認日曆,你選擇你希望它被放入的日曆。我有一個問題,你選擇它的方式,因爲一些日曆工作,但不是其他人。EKCalendar錯誤

+0

你當你保存到'eventStore',或當你'setCalendar的錯誤:'? –

+0

,當我試圖將事件保存到日曆 – user794543

回答

0

您設置您的活動日曆兩次

[event setCalendar:c]; 
[event setCalendar:[[eventStore calendars]objectAtIndex:calendararray]]; 

請告訴我你在哪裏得到calendararray是一個數組?我似乎更像一個indexKey。


而不是你選擇的日曆P將索引,通過它的標題,比如:​​或calendar.title。然後使用此標題查找編輯和不可編輯完整列表中的標題。


UPDATE

就做這樣的事情:

EKCalendar *theSelectedCalendar; 
// selectedCalendarTitle comes from your delegate instead of your index... 

for (EKCalendar *thisCalendar in eventStore.calendars){ 
    if ([thisCalendar.title isEqualToString:selectedCalendarTitle]){ 
     [event setCalendar:thisCalendar]; 
    } 
} 

更新2

EKCalendar *theSelectedCalendar; 
// selectedCalendarTitle comes from your delegate instead of your index... 

for (int i=0; i<=([eventStore.calendars count]-1); i++) { 
    if ([[[[eventStore calendars]objectAtIndex:i] title] isEqualToString:selectedCalendarTitle]){ 
     [event setCalendar:[[eventStore calendars]objectAtIndex:i]]; 
    } 
} 

更新3

//Present the picker populated with the array: eventStore.calendars. This should return the index and store it in: indexOfSelectedCalendarFromEventSoreCalendars 

if ([[[eventStore calendars] objectAtIndex:indexOfSelectedCalendarFromEventSoreCalendars] allowsContentModifications]){ 
    [event setCalendar:[[eventStore calendars] objectAtIndex:indexOfSelectedCalendarFromEventSoreCalendars]]; 

} else { 
    NSLog(@"Selected calendar cannot be modified."); //Present the picker again for the user to select another calendar. 
} 
+0

他們在2個獨立的意見,讓我用一個代表,它的選擇器爲int calendarArray的行索引轉移; – user794543

+0

你檢查了變量的值嗎? –

+0

什麼ü用支票意味着 – user794543