ios – 獲取所有日歷時出錯:錯誤域= EKCADErrorDomain代碼= 1013“(null)”Swift 3

    我有一個應用程序,應該將日歷列表加載到pickerview中.它可以工作,但只有在應用程序崩潰并再次打開之后.我不確定為什么它不適用于應用程序得初始打開.

    日歷權限請求:

    func requestCalendarPermissions() {eventInstance.requestAccess(to: .event,completion: {(accessGranted: Bool,error: Error?) in    if accessGranted == true {        print("Access Has Been Granted")        }    else {        print("Change Settings to Allow Access")    }    })}

    檢查權限狀態:

    func checkStatus() {let currentStatus = EKEventStore.authorizationStatus(for: EKEntityType.event)if currentStatus == EKAuthorizationStatus.notDetermined {    requestCalendarPermissions()}else if currentStatus == EKAuthorizationStatus.authorized {    print("Access Has Been Granted")}else if (currentStatus == EKAuthorizationStatus.denied) || (currentStatus == EKAuthorizationStatus.restricted){    print("Access Has Been Denied")}}

    PickerView代碼:

    func numberOfComponents(in pickerView: UIPickerView) -> Int {    return 1}func pickerView(_ pickerView: UIPickerView,numberOfRowsInComponent component: Int) -> Int {    return calendars.count}func pickerView(_ pickerView: UIPickerView,titleForRow row: Int,forComponent component: Int) -> String? {    return calendars[row].title}func pickerView(_ pickerView: UIPickerView,didSelectRow row: Int,inComponent component: Int) {    CalendarField.text = calendars[row].title    calID = calendars[row].calendarIdentifier}

    出現此錯誤:

    Error getting all calendars: Error Domain=EKCADErrorDomain Code=1013 “(null)”

    該應用程序最終崩潰,因為它試圖填充pickerView并且沒有數據要填充.我加載日歷.

    但是,由于某些原因,在應用程序崩潰并重新打開后不會發生這種情況.

    謝謝

    [更新]

    控制臺出:

    2016-11-26 18:04:23.856 PTF[98143:2347570] Error getting all
    calendars: Error Domain=EKCADErrorDomain Code=1013 “(null)” Calendars
    Loaded 2016-11-26 18:04:23.869 PTF[98143:2347569] Error getting all
    calendars: Error Domain=EKCADErrorDomain Code=1013 “(null)” Calendars
    Loaded

    Access Has Been Granted 2016-11-26 18:04:25.954 PTF[98143:2347569]
    Error getting all calendars: Error Domain=EKCADErrorDomain Code=1013
    “(null)” Calendars Loaded

    2016-11-26 18:04:46.620 PTF[98143:2347522] * Terminating app due to
    uncaught exception ‘NSRangeException’,reason: ‘*
    -[NSArray0
    objectAtIndex:]: index 0 beyond bounds for empty NSArray’
    *** First throw call stack: ( 0 CoreFoundation 0x000000010bb6634b __exceptionPreprocess + 171 1 libobjc.A.dylib
    0x000000010b5c721e objc_exception_throw + 48 2 CoreFoundation
    0x000000010bb7dddd -[__NSArray0 objectAtIndex:] + 93 3
    libswiftCore.dylib 0x000000010d95311d
    _TFVs12_ArrayBuffer19_getElementSlowPathfSiPs9AnyObject_ + 125 4 libswiftCore.dylib 0x000000010d953003
    _TFVs12_ArrayBuffer10getElementfTSi20wasNativeTypeCheckedSb_x + 147 5 libswiftCore.dylib 0x000000010d963b8a
    _TFSag9subscriptFSix + 138 6 PTF 0x000000010af8df12
    _TFC3PTF19MainScreenTableView10pickerViewfTCSo12UIPickerView12didSelectRowSi11inComponentSi_T_
    + 226 7 PTF 0x000000010af8e10a _TToFC3PTF19MainScreenTableView10pickerViewfTCSo12UIPickerView12didSelectRowSi11inComponentSi_T_
    + 74 8 UIKit 0x000000010c0d301d -[UIPickerView _sendSelectionChangedForComponent:notify:] + 104 9 UIKit 0x000000010c0d326e -[UIPickerView
    _sendSelectionChangedFromTable:notify:] + 370 10 UIKit 0x000000010c8a560d -[UIPickerTableView _scrollingFinished] + 187 11
    UIKit 0x000000010c8a57fd
    -[UIPickerTableView scrollViewDidEndDecelerating:] + 30 12 UIKit 0x000000010c1df821 -[UIScrollView(UIScrollViewInternal)
    _scrollViewDidEndDeceleratingForDelegate] + 91 13 UIKit 0x000000010c1dc362 -[UIScrollView(UIScrollViewInternal)
    _stopScrollDecelerationNotify:] + 316 14 UIKit 0x000000010c1dc5b9 -[UIScrollView(UIScrollViewInternal)
    _stopScrollingNotify:pin:tramplingDragFlags:] + 505 15 UIKit 0x000000010c1d4503 -[UIScrollView _smoothScrollWithUpdateTime:] + 3304
    16 QuartzCore 0x0000000113fa3bd5
    _ZN2CA7Display15DisplayLinkItem8dispatchEy + 57 17 QuartzCore 0x0000000113fa3a95 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy +
    449 18 CoreFoundation 0x000000010baf8964
    __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
    + 20 19 CoreFoundation 0x000000010baf85f3
    __CFRunLoopDoTimer + 1075 20 CoreFoundation 0x000000010baf817a __CFRunLoopDoTimers + 250 21 CoreFoundation
    0x000000010baeff01 __CFRunLoopRun + 2065 22 CoreFoundation
    0x000000010baef494 CFRunLoopRunSpecific + 420 23 GraphicsServices
    0x000000011124aa6f GSEventRunModal + 161 24 UIKit
    0x000000010c0eff34 UIApplicationMain + 159 25 PTF
    0x000000010af9f36f main + 111 26 libdyld.dylib
    0x000000010f30368d start + 1 ) libc++abi.dylib: terminating with
    uncaught exception of type NSException

    解決方法

    我剛遇到這個問題.在’requestAccess’之后,文檔說在eventInstance上調用’reset’.然而,即使這樣也沒有讓事情發生.然而,獲得一個新得eventInstance.我正在使用Objective c,所以我發布了我正在使用得EKEventStore對象并分配了一個新對象.

    以上是來客網為你收集整理得ios – 獲取所有日歷時出錯:錯誤域= EKCADErrorDomain代碼= 1013“(null)”Swift 3全部內容,希望內容能夠幫你解決ios – 獲取所有日歷時出錯:錯誤域= EKCADErrorDomain代碼= 1013“(null)”Swift 3所遇到得程序開發問題。

    如果覺得來客網網站內容還不錯,歡迎將來客網網站推薦給程序員好友。

    聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。
    發表評論
    更多 網友評論1 條評論)
    暫無評論

    返回頂部

    主站蜘蛛池模板: 激情亚洲一区国产精品| 中文字幕在线观看一区二区| 日本在线不卡一区| 国内精品视频一区二区三区| 无码少妇一区二区三区| 日本一区二区三区精品国产| 人妻无码视频一区二区三区| 能在线观看的一区二区三区| 日本一区二三区好的精华液 | 亚洲一区二区三区首页| 一区二区三区四区在线播放| 中文字幕日韩精品一区二区三区 | 久久无码人妻一区二区三区午夜| 欧洲精品码一区二区三区| 国产乱码一区二区三区四| 麻豆天美国产一区在线播放| 日本在线一区二区| 精品一区二区三区中文字幕| 国产一区二区精品久久| 中文字幕亚洲一区二区va在线| 亚洲av区一区二区三| 亚洲欧洲一区二区三区| 中文字幕国产一区| 国产一区二区免费在线| 成人区人妻精品一区二区三区| 51视频国产精品一区二区| 麻豆一区二区免费播放网站| 亚洲AV无码一区二区三区牲色| 日韩成人无码一区二区三区| 国产精品视频一区麻豆| 最新中文字幕一区二区乱码| 日韩色视频一区二区三区亚洲| 色噜噜一区二区三区| 无码国产精品一区二区免费vr | 91亚洲一区二区在线观看不卡| 色欲综合一区二区三区| 久久久久久人妻一区二区三区| 中文字幕AV一区二区三区人妻少妇| 国产成人综合一区精品| 欧美人妻一区黄a片| 日韩电影在线观看第一区|