一个简单的 Swift 包,用于访问斯特拉斯堡停车场的开放数据(位置 API 和 可用性 API)
参考文档请见这里。
您可以使用回调闭包响应、Combine 或 async 方法与该框架交互
let client = ParkingAPIClient()
client.getLocations { (result) in
switch result {
case .success(let locations):
print("Locations: \(locations)")
case .failure(let error):
print("Error during the download: \(error)")
}
}
let client = ParkingAPIClient()
client.getLocationsPublisher().sink { result in
if case .failure(let error) = result {
print("Error: \(result)")
}
} receiveValue: { result in
print("Response: \(result)")
}
let client = ParkingAPIClient()
do {
let response = try await client.fetchLocations()
print("Response: \(response)")
} catch let error {
print("Error: \(error)")
}