Post

Replies

Boosts

Views

Activity

xcode quit unexpectedly
I want to read almost a million addresses in foor loop using CLGeocoder and save their coordinates. I have also put a 2 second pause in each loop, but every time I want to run the program in Xcode, after 200 or 300 iterations, the program closes suddenly. Does anyone know the reason? Is there a problem with the code? here is my code : func createCSV(from recArray:[Dictionary<String, AnyObject>]) {     var csvString = "\("Adresse");\("latitute ");\("longitude")\n\n"     for dct in recArray {       csvString = csvString.appending("\(String(describing:dct["Adresse"]!));\(String(describing: dct["latitute"]!));\(String(describing: dct["longitude"]!))\n")     }     let fileManager = FileManager.default     do {       let path = try fileManager.url(for: .documentDirectory, in: .allDomainsMask, appropriateFor: nil, create: false)       let fileURL = path.appendingPathComponent("CSVRec.csv")       try csvString.write(to: fileURL, atomically: true, encoding: .utf8)     } catch {       print("error creating file")     }   } func getLocation(for address: String) async throws -> CLLocationCoordinate2D {       guard let coordinate = try? await CLGeocoder().geocodeAddressString(address) else {     throw getLocationError.unableToGetLocation   }       return coordinate.first!.location!.coordinate      } var Coordinates:[Dictionary<String, AnyObject>] = Array() var address: String for row in result.rows {   address = "\(row["LABE"] ?? "") \(row["HAUS"] ?? ""), \(row["Gemeindename"] ?? "")"   var coordinate = try await getLocation(for: address)   var dct = Dictionary<String, AnyObject>()   dct.updateValue(address as AnyObject, forKey: "Adresse")   dct.updateValue(coordinate.latitude as AnyObject, forKey: "latitute")   dct.updateValue(coordinate.longitude as AnyObject, forKey: "longitude")   Coordinates.append(dct)   sleep(2) } createCSV(from: Coordinates) Does anyone have an idea what to do?
1
0
906
Nov ’22
how to write a function that takes coordinate(lat - long) and take snapshot from desired location with lookaround.snapshotter in Swift?
I just started programming in Swift and I am a complete beginner. I wanted to write a function or class that, by receiving the coordinates, if there is a photo in MKLookAround.request, saves a photo of the desired location using MKLookAround.Snapshotter, but I don't know how to use the mapkit ready classes. I don't want to use swiftUI, I just want to save pictures for a number of coordinates from different places.
1
0
620
Oct ’22