Post

Replies

Boosts

Views

Activity

Reply to Data Persistence and Core Data with SwiftUI
Core Data with SwiftUI Create the Core Data container once when the app starts Inject its managed object context into the environment Perform fetch requests directly on there NSManagedObject conforms to the ObservableObject protocol which means we can bind any object to part of our user interface There’s a managedObjectContext key in the environment designed to store our active Core Data managed object context We then inject that context into the initial content view. There’s a @FetchRequest property wrapper that uses the environment’s managed object context to perform fetch requests You'll have to recreate your Task struct as an NSManagedObject, and it won't behave quite the same, so you'll have a bit of work to do.
Aug ’22
Reply to MKPolyline loses border when zooming
Yes, that's a doozy. I am seeing the problem in the Simulator, and on a real device. I have simplified your code (using only the first polygon), in case anyone else wants to try it: import MapKit import UIKit class ViewController: UIViewController { @IBOutlet weak var mapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() mapView.delegate = self let coordinates: [CLLocationCoordinate2D] = [ CLLocationCoordinate2D(latitude: 50.59718623058702, longitude: 8.6572265625), CLLocationCoordinate2D(latitude: 50.59718623058702, longitude: 8.67919921875), CLLocationCoordinate2D(latitude: 50.58323661480589, longitude: 8.67919921875), CLLocationCoordinate2D(latitude: 50.58323661480589, longitude: 8.6572265625) ] let polygon = MKPolygon(coordinates: coordinates, count: coordinates.count) mapView.addOverlay(polygon) mapView.centerCoordinate = polygon.coordinate mapView.region.span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1) } } extension ViewController: MKMapViewDelegate { func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { if let polygon = overlay as? MKPolygon { let renderer = MKPolygonRenderer(polygon: polygon) renderer.strokeColor = .black renderer.lineWidth = 5 return renderer } return MKOverlayRenderer(overlay: overlay) } } On zooming in, the polygon loses one of it's sides, then another one.
Jul ’22