CKError localizedDescription

后端 未结 2 1813
醉话见心
醉话见心 2021-01-18 05:50

Aim

  • I would like to display the CKError encountered to the user in the app as an alert.
  • So I would like to extract the string from the
相关标签:
2条回答
  • 2021-01-18 06:26

    Looks like there is another error in the errorUserInfo[NSUnderlyingError]. Try getting the localizedDescription from that error.

    So, that would be:

    ((error as? CKError)?.errorUserInfo[NSUnderlyingErrorKey] as? NSError)?.localizedDescription
    
    0 讨论(0)
  • 2021-01-18 06:43

    The error.localizedDescription is really all you have to work with from the error itself.

    Your app can provide a better error message (more user-friendly, localized, etc.) by checking for the error code and providing its own message to the user.

    (error as? NSError)?.code
    
    0 讨论(0)
提交回复
热议问题