how to get ekevent EKparticipant email?

前端 未结 6 929
花落未央
花落未央 2020-12-10 04:21

how to get ekevent EKparticipant email?

EKParticipant class does not have such a attribute.

Is it possible to render the native ios participants controller t

6条回答
  •  渐次进展
    2020-12-10 05:07

    Based on Anton Plebanovich's answer I've made this Swift 5 solution for this made up problem Apple introduced:

    Swift 5

    private let emailSelector = "emailAddress"
    extension EKParticipant {
      var email: String? {
        if responds(to: Selector(emailSelector)) {
          return value(forKey: emailSelector) as? String
        }
    
        let emailComponents = description.components(separatedBy: "email = ")
        if emailComponents.count > 1 {
          return emailComponents[1].components(separatedBy: ";")[0]
        }
    
        if let email = (url as NSURL).resourceSpecifier, !email.hasPrefix("/") {
          return email
        }
    
        return nil
      }
    }
    

提交回复
热议问题