2015-02-03 6 views
0

모든 앱 관련 일정을 만들 수있는 맞춤 캘린더를 만들고 싶습니다. 나는이 달력에 EKSourceTypeLocal이되고 싶습니다.iPhone에서 일정을 만들 수는 없지만 시뮬레이터에서 수행 할 수 있습니다.

시뮬레이터에 캘린더를 만들고 이벤트를 추가 할 수 있지만 iPhone에 추가하려고하면 작동하지 않습니다. 달력 식별자가 NSUserDefaults에있는 경우

if (eventManager.eventStore?.calendarWithIdentifier(NSUserDefaults.standardUserDefaults().objectForKey("calendar_identifier") as? String) == nil){ 
     //The calendar doesn't exist, create a new one with the correct properties. 
     calendar = EKCalendar(forEntityType: EKEntityTypeEvent, eventStore: eventManager.eventStore) 
     calendar.title = "My Calendar" 
     calendar.CGColor = UIColor(red: 0, green: 0.62, blue: 0.10, alpha: 1).CGColor 
     // Find the proper source type value. 
     var localSource:EKSource? = nil 

     if let eventStore = eventManager.eventStore{ 
     //get the correct source for the calendar 
      for source in eventStore.sources() as [EKSource] { 
       println("eventStore.source - \(source)") 
       switch (source.sourceType.value){ 
       /* 
       case (EKSourceTypeSubscribed.value): 
        localSource = source 
       */ 
       case (EKSourceTypeLocal.value): 
        localSource = source 
       default: 
        break 
       } 
      } 
      calendar.source = localSource 
      } 
      //save the newly created calendar 
      eventManager.eventStore!.saveCalendar(calendar, commit: true, error: &error) 
      //check for any errors. 
      if(error == nil){ 
       //no errors were encountered save identifier 
       NSUserDefaults.standardUserDefaults().setObject(calendar.calendarIdentifier, forKey: "calendar_identifier") 
        println("Making calendar") 
      }else{ 
        println("error in making calendar - \(error?.localizedDescription)") 
        return 
      } 
     } 

내가 먼저 확인 :

내 코드는 달력을 만들 수 있습니다. 그런 다음 새 달력을 만들고 찾으면 로컬 소스를 할당합니다. (. 작동 true를 돌려줍니다) 그 때 나는 오류가 반환되지 않습니다 달력을 저장하고 나는 소스를 인쇄 할 때이 제공 :

EKSource <0x1700dad30> {UUID = BD42B102-A185-4A93-9114-737001A4C408; type = Local; title = Default; externalID = (null)} 

내가 잘못 여기서 뭐하는 거지, 또는 더 나은 방법은 무엇입니까?

답변

0

iCloud에서 버그/비정상적인 동작 인 것 같습니다.

iCloud가 활성화되어 있지만 미리 알림을 동기화하지 않도록 설정 한 경우 이런 일이 발생합니다. This Guy에도 같은 문제가 있었지만 해결할 수 없었습니다.

미리 알림 동기화를 사용하도록 설정하십시오.

관련 문제