Sunday, October 2, 2022
HomeiOS Developmentios - Conversion of Integer array to Location coordinates will not be...

ios – Conversion of Integer array to Location coordinates will not be working in iPadOS 16 Beta


Im dealing with one concern in iPadOS 16 Beta (16.1 launch). The problem was in my software server ship response in Integer array and we’ve got to transform that Integer array to location coordinates. Discover my hooked up code.

func convertIntergerArrayToCoordinates(_ values: [Int]) -> CLLocationCoordinate2D? {
    func toBytes(withArrayOfInts numbers: [Int]?) -> [UInt8] {
        guard let numbers = numbers else { return [] }
        return numbers.map({ UInt8($0) })
    }

    func sliceToArray<T>(withSlice slice: ArraySlice<T>?) -> [T] {
        guard let slice = slice else { return [] }
        return slice.map { $0 }
    }

    let capability: Int = 8
    if let latitude = toBytes(withArrayOfInts: sliceToArray(withSlice: values[0..<capacity])).withUnsafeBufferPointer({ $0.baseAddress })?.withMemoryRebound(to: Double.self, capability: capability, { $0.pointee }), let longitude = toBytes(withArrayOfInts: sliceToArray(withSlice: values[capacity..<capacity*2])).withUnsafeBufferPointer({ $0.baseAddress })?.withMemoryRebound(to: Double.self, capability: capability, { $0.pointee }) {
        return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
    } else {
        return nil
    }
}

This code was working completely for iOS 16 newest Beta however not working in iPadOS 16 newest beta. Kindly share you anybody having thought on this.

Discover my Enter:

let values = [184, 173, 45, 60, 47, 201, 71, 64, 190, 200, 241, 48, 90, 142, 94, 192, 33, 179, 0]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments