2012-03-03 1 views
1

미리 알림 구성 요소가있는 앱에서 작업하고 있습니다. Calendar Store을 사용하여 캘린더 목록을 가져오고, 사용자가 원하는 캘린더를 선택하여 작업을 추가하려고합니다. 문제는 CalCalendar 이벤트 캘린더와 작업 캘린더를 구별하지 않는 것 같습니다.캘린더 저장소 : 일정 관리와 일정 관리를 구분하는 방법은 무엇입니까?

NSArray* calendars = [[CalCalendarStore defaultCalendarStore] calendars]; 
for(CalCalendar* aCalendar in calendars) { 
    if(aCalendar.isEditable) { 
     NSLog(@"editable calendar: %@", aCalendar); 
    } 
} 

이 출력 :

editable calendar: CalCalendar <0x6e04d10> {UID = 8AA8FFAD-D781-47F7-9231-CF66E1753983; title = Work; notes = (null); color = NSCalibratedRGBColorSpace 0.054902 0.380392 0.72549 1; type = CalDAV; editable = 1} 
editable calendar: CalCalendar <0x6e05000> {UID = A7F4A1B2-D1CF-4A20-9F84-CD1A1E99773E; title = Home; notes = ; color = NSCalibratedRGBColorSpace 0.72549 0.054902 0.156863 1; type = CalDAV; editable = 1} 
editable calendar: CalCalendar <0x6e050f0> {UID = 43B14D2A-9976-461C-8EFE-5FA029381828; title = Personal; notes = (null); color = NSCalibratedRGBColorSpace 0.901961 0.784314 0 1; type = CalDAV; editable = 1} 
editable calendar: CalCalendar <0x6e05140> {UID = F42EC365-20AC-4251-B45E-FB7F169928F0; title = Mac; notes = (null); color = NSCalibratedRGBColorSpace 0.054902 0.380392 0.72549 1; type = Local; editable = 1} 
editable calendar: CalCalendar <0x6e05190> {UID = FF771FF9-3969-4001-BBA4-9B7B00E80291; title = Cloud 2; notes = (null); color = NSCalibratedRGBColorSpace 0.054902 0.380392 0.72549 1; type = CalDAV; editable = 1} 
editable calendar: CalCalendar <0x6e051e0> {UID = 40234537-869C-4CC2-89B9-DD4F7D36C169; title = Groceries; notes = ; color = NSCalibratedRGBColorSpace 0.443137 0.101961 0.462745 1; type = CalDAV; editable = 1} 

내가 처음이 이벤트 달력 것을 알고, 마지막 4 작업 목록입니다. iCal은 이벤트에 대한 이벤트 캘린더와 작업에 대한 작업 캘린더 만 표시하므로 차이점을 확실히 알고 있습니다.

하지만 캘린더 저장소 API를 통해 프로그래밍 방식으로이를 확인할 방법이없는 것처럼 보입니다.

업데이트 : rdar://10377730과 같이이 사실을 눈치 챌 수있는 유일한 사람은 아닙니다. 방금 내 자신의 보고서를 제출했습니다. rdar://10980542

답변

1

저는 매우 만족스럽지 않지만 지금 사용하고있는 해결 방법은 각 캘린더에서 작업을 만들려고 시도하는 것입니다. 이벤트 일정 관리에서 작업을 만들려고하면 오류가 발생합니다. 조금 닮은 것 같습니다 :

- (BOOL) isCalendarAUsableTaskList:(CalCalendar*)aCalendar 
{ 
    if(!aCalendar.isEditable) return NO; 

    // Try to make a task here. 
    CalTask* newTask = [CalTask task]; 
    newTask.calendar = aCalendar; 
    newTask.title = @"Test Item"; 
    NSError* anError = nil; 
    if(![[CalCalendarStore defaultCalendarStore] saveTask:newTask error:&anError]) { 
     // Couldn't make a task, this calendar is no bueno. 
     NSLog(@"Error saving task to calendar %@ (%@)", aCalendar.title, [anError localizedDescription]); 
     return NO; 
    } 

    // Created a task. Now clean up on our way out. 
    NSLog(@"Saved task to calendar %@", aCalendar.title); 
    [[CalCalendarStore defaultCalendarStore] removeTask:newTask error:nil]; 

    return YES; 
}