2017-05-16 12 views
2

ユーザーがカレンダーから手動でイベントを削除し、アプリケーションがEKEventStoreから識別子を持つEKEventを取得しようとすると、アプリケーションが以下のエラーでクラッシュします。ここで カレンダーからの識別子でイベントを取得中にアプリケーションがクラッシュする

Error getting event with identifier AB78AC19-BD17-4290-8A21-4BF948089C12:66F6F5BC-BF61-401A-B808-44A555F7E63E: Error Domain=EKCADErrorDomain Code=1010 "The operation couldn’t be completed. (EKCADErrorDomain error 1010.)" fatal error: unexpectedly found nil while unwrapping an Optional value

let eventStore = EKEventStore() 
let event = eventStore.event(withIdentifier: identifier as String)! 

このことから私を助けてください識別子でイベントを取得するためのコードを使用することです。

答えて

1

チェックイベントが存在する場合は:

let eventStore = EKEventStore() 
if let event = eventStore.event(withIdentifier: identifier as String) { 
    //do what you need with the event 
} 
+0

おかげで、これは私のために動作します。 – Shubham

関連する問題