-2
swift 3とswift 4に更新した後にエラーが発生しました。エラースレッド1:EXC_BREAKPOINT(コード= 1、サブコード= 0x10039fb00)
let eventStore = EKEventStore();
let newCalendar = EKCalendar(for: .event, eventStore: eventStore)
newCalendar.title = newPatientCal.text ?? "Add New Calendar"
let sourcesInEventStore = eventStore.sources
newCalendar.source = sourcesInEventStore.filter{
(source: EKSource) -> Bool in
source.sourceType.rawValue == EKSourceType.local.rawValue
}.first! // <---- Error occurs here; removed "!" but still have error
do {
try eventStore.saveCalendar(newCalendar, commit: true)
UserDefaults.standard.set(newCalendar.calendarIdentifier, forKey: "PatientTrackingCalendar")
newPatDelegate.calDidAdd()
self.dismiss(animated: true, completion: nil)
} catch {
let alert = UIAlertController(title: "Could not save new Calendar", message: (error as NSError).localizedDescription, preferredStyle: .alert)
let oKAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(oKAction)
self.present(alert, animated: true, completion: nil)
}
は安全にoptionalsのラップを解除することを学びます。 – rmaddy
Swift 3または4にアップデートしようとしていますか? – Sneha