Post

Replies

Boosts

Views

Activity

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
Reply to MKPolyline loses border when zooming
Ah, this is interesting... If I replace the coordinates with: CLLocationCoordinate2D(latitude: 50.597186, longitude: 8.657226), CLLocationCoordinate2D(latitude: 50.597186, longitude: 8.679199), CLLocationCoordinate2D(latitude: 50.583236, longitude: 8.679199), CLLocationCoordinate2D(latitude: 50.583236, longitude: 8.657226) ...it works!
Jul ’22
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.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to System requirements for Xcode 14
From the Xcode 14 Beta Release Notes Xcode 14 beta requires a Mac running macOS Monterey 12.4 or later. Some features require Apple silicon, but Xcode 14 itself does not.
Replies
Boosts
Views
Activity
Jun ’22
Reply to I am trying to log touch coordinates into the CSV file, but I am getting "No exact matches in call to initializer" error
Instead of: let mylocation = String(location) Try: let mylocation = String("\(location.x),\(location.y)")
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to Need to fix error, "Missing argument for parameter 'scannedCode' in call"
In the Preview, you need to pass a "scannedCode" to your "PageThree" struct. Try this: struct PageThree_Previews: PreviewProvider { static var previews: some View { PageThree(scannedCode: "some text...") } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to MKPolyline loses border when zooming
It is most likely caused by: renderer.lineWidth = 0.7 Try... renderer.lineWidth = 1 ...and see if that fixes it.
Replies
Boosts
Views
Activity
Jul ’22
Reply to Disabling Push Notifications
No, users can always disable notifications in Settings.
Replies
Boosts
Views
Activity
Jul ’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.
Replies
Boosts
Views
Activity
Jul ’22
Reply to MKPolyline loses border when zooming
Ah, this is interesting... If I replace the coordinates with: CLLocationCoordinate2D(latitude: 50.597186, longitude: 8.657226), CLLocationCoordinate2D(latitude: 50.597186, longitude: 8.679199), CLLocationCoordinate2D(latitude: 50.583236, longitude: 8.679199), CLLocationCoordinate2D(latitude: 50.583236, longitude: 8.657226) ...it works!
Replies
Boosts
Views
Activity
Jul ’22
Reply to MKPolyline loses border when zooming
Well, that was an interesting one! It's hard to understand why the original code is failing, but at least you have a workaround. Thanks for accepting my answer.
Replies
Boosts
Views
Activity
Jul ’22
Reply to Natural Frequency for accessing location data from apple
No recommended frequency - that's not how it works. You register for location updates, then your CLLocationManagerDelegate "didUpdateLocations" is called by the system, whenever the location has changed by a significant distance (which you can specify).
Replies
Boosts
Views
Activity
Jul ’22
Reply to Type Properties in Extensions
sampleData is an array of DailyScrum. It is a "let" constant, it cannot be changed. It is a computed property... it is computed at compile time.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Binary operator '+' cannot be applied to operands of type '()' and 'String' error
Perhaps you mean this? func addDance(_ sentence: String) -> String { return sentence + " and then we dance" }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Crash when using String(cString:)
Your String init assumes that the data is encoded using UTF-8. Could it be that in some cases, the cString is not encoded using UTF-8? (You can specify the encoding to use, when creating your String.)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to IOS Development
Paul Hegarty's cs193p course at Stanford is top notch. 2021, but well worth a look. https://cs193p.sites.stanford.edu/
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Email validation using RegEx and TextField text color
Using a regular expression to validate an email address is doomed to failure. To do this properly, use NSDataDetector, or NSPredicate. There's a nice take on this here: https://www.swiftbysundell.com/articles/validating-email-addresses/
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
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.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22