【问题标题】:How to join array of array locations with zero location?如何连接具有零位置的数组位置数组?
【发布时间】:2018-07-11 05:54:48
【问题描述】:

这是我试图实现的目标:

let a = CLLocation(latitude: 10, longitude: 20)
let b = CLLocation(latitude: 10, longitude: 40)
let c = CLLocation(latitude: 10, longitude: 60)
let d = CLLocation(latitude: 10, longitude: 80)

let aa = [a, b]
let bb = [c, d]

let zero = CLLocation(latitude: 0, longitude: 0)

let cc = [aa, bb].joined(separator: zero)

我需要这样的东西:

let output = [a, b, zero, c, d]

传递给不带参数的调用的参数

【问题讨论】:

    标签: swift core-location


    【解决方案1】:

    分隔符也必须是数组:

    let cc = [aa, bb].joined(separator: [zero])
    print(Array(cc))
    

    【讨论】:

    • 更具体地说,传递给joined的值必须与数组中的类型相同,在这种情况下为[CLLocation]
    • 你试过了吗:let cc = [aa, bb].joined(separator: [zero])
    猜你喜欢
    • 2021-08-14
    • 1970-01-01
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    相关资源
    最近更新 更多