Post

Replies

Boosts

Views

Activity

Reply to MKMapView: Why are my MKPolyline(s) invisible?
Seems the current KMLParser cannot detect the right styles for LineString from xml file. You can set some fixed value in overlayPathRenderer: var overlayPathRenderer: MKOverlayPathRenderer? { if _overlayPathRenderer == nil { if let overlay = self.overlay { _overlayPathRenderer = geometry?.createOverlayPathRenderer(overlay as! MKShape) if let renderer = _overlayPathRenderer as? MKPolylineRenderer { renderer.strokeColor = .blue renderer.lineWidth = 2 } style?.applyToOverlayPathRenderer(_overlayPathRenderer!) } } return _overlayPathRenderer }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to How to declare a scope in code ?
There is not other method to declare the scope beside creating a new SwiftUI view file ? Correct. The scope is defined by the definitions. You can add AdvancedSettingsView in the same file if you prefer. But anyway, you need a definition of AdvancedSettingsView somewhere in your project.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to How to declare a scope in code ?
Cannot find AdvancedSettingsView in scope ? As already said in another thread of yours, the scope for type names is usually whole your project. You may need to add AdvancedSettingsView.swift into your project and write the right definition of AdvancedSettingsView in it. Please be careful about spellings.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to String.self isn't compatible with AnyClass in ValueTransformer
This was the code that seemed to compile circa 2016. As far as I know, none of the Swift compilers accepted String.self as AnyClass. And at least in Xcode 8.3.3 (early 2017, I think), it does not compile. You may be confused with something else. So is the correct approach to work with NSStrings in ValueTransformers? It is not clear what you really want to do so not sure if it is correct or not. But usually NSString in Objective-C side would automatically converted to String in Swift. If you could clarify what you were trying to do, I would be able to show some example.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Wait until transaction is finished
How can I wait until an IAP transaction/restore is finished? Hard to say something concrete and sure without seeing the details, but you may need to change your way of thinking. Not wait until, but do something when. If you were accustomed to completion handler pattern, it would not be so difficult.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to How do I properly use class variables?
it appears I was misunderstanding the way the static keyword works in Swift. I hope you have noticed that showing what you tried would give you the solution sooner. it does provide a cleaner solution to tie this to the class rather than making it a true global. It depends on how a is used. But in most cases it might be a clearer solution. Hoping yours would not be an exception. By the way, in Swift you use Capitalized identifiers for types. You should better follow the basic coding rule of Swift if you continue coding in Swift.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to MKPolyline 'inside' an MKOverlay: How do I access the points that construct the line?
If you want to unconvert MKMapPoint in MKPolyline to CLLocationCoordinate2D, you may need a little more complex code. Please add these lines in the code where overlays is valid: overlays.forEach {overlay in if let polyline = overlay as? MKPolyline { var coords = Array(repeating: CLLocationCoordinate2D(), count: polyline.pointCount) polyline.getCoordinates(&coords, range: NSRange(0..polyline.pointCount)) print(coords) } } Have a good sleep.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21