【问题标题】:iOS swift : get location from event.structuredLocation of calendar entryiOS swift:从日历条目的 event.structuredLocation 获取位置
【发布时间】:2021-01-12 01:26:54
【问题描述】:

我评估日历数据并希望继续使用 CLLoation 格式的数据,但是:

    po structuredLocation! .geoLocation! .value (forKey: "course") or similar

我没有得到纬度/经度吗? 它是如何工作的?

    func getLocationOfEvent(event: EKEvent, eventLocation: inout CLLocation?) 
    -> String {
      var structuredLocation: EKStructuredLocation?
    
      if event.location != nil {
        structuredLocation = event.structuredLocation
        eventLocation = event.structuredLocation!.geoLocation
      }
    
      if event.location == nil {
        return "<<<Location>>>"
    } else {
        return event.location!    /// String
    }
}

从调试器: (lldb) po 结构化位置!.geoLocation! +/- 0.00m(速度 -1.00 mps / 路线 -1.00)@ 25.09.20, 18:57:08 Mitteleuropäische Sommerzeit

它是如何工作的?或者谁知道该怎么做? 感谢任何帮助

【问题讨论】:

    标签: ios swift dictionary calendar


    【解决方案1】:

    您可以从 EKEventStructuredLocation 中找到纬度、经度、海拔和其他信息。

    if event.location != nil {
        structuredLocation = event.structuredLocation
        print(event.structuredLocation?.geoLocation?.coordinate.latitude)
        print(event.structuredLocation?.geoLocation?.coordinate.longitude)
        print(event.structuredLocation?.geoLocation?.altitude)
            
      }
    

    将此属性添加到您的 CLLocation 对象中,您就可以开始了...

    【讨论】:

      猜你喜欢
      • 2021-11-11
      • 1970-01-01
      • 2011-11-12
      • 1970-01-01
      • 2015-11-08
      • 2023-02-21
      • 1970-01-01
      • 1970-01-01
      • 2012-12-12
      相关资源
      最近更新 更多