Post

Replies

Boosts

Views

Activity

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
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 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 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 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 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 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 ?
My issue is the following : "I want to program a function and I receive a 'scope' error". How do I declare a scope and were in my programming code to allow the variable to function in accordance with the iOS Mobile App that I want to develop these year ? As already said, scope is not something you define. Ignore the word scope in the error message and find what you need to define. What you need to do is described in the other parts than scope in the error message. If you get Cannot find AdvancedSettingsView in scope, it is AdvancedSettingsView that you need to define, not scope.
Topic: UI Frameworks SubTopic: SwiftUI 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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
May ’21
Reply to How to declare protocol ?
How do I declare protocol App in context ? The protocol App is defined in the framework SwiftUI, which is not something you need to define. Do you get any sort of errors with your shown code?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
May ’21
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:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
The thing is, there is no error, it just calls completion() too early. Because you write completion() where it is called too early.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
So then, how do I write completion in the correct place? Seems I need to repeat, you need to clarify where is the correct place
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
After the transaction has taken place. So, where is the place where the transaction has taken place?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Wait until transaction is finished
Seems you are writing code before you understand the behavior of the framework you are using...
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to UICollectionView Layout Error: nil layout parameter
Your code lacks many parts and I cannot run your code. Can you show a complete code I can run and test easily?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to How can I call Swift extension method in my Objective-C class?It doesn't work when using @objc.
What should I do for the Swift extension method? You should better show what you have done till now. Can you show all the relevant codes?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to How to declare a scope in code ?
My issue is the following : "I want to program a function and I receive a 'scope' error". How do I declare a scope and were in my programming code to allow the variable to function in accordance with the iOS Mobile App that I want to develop these year ? As already said, scope is not something you define. Ignore the word scope in the error message and find what you need to define. What you need to do is described in the other parts than scope in the error message. If you get Cannot find AdvancedSettingsView in scope, it is AdvancedSettingsView that you need to define, not scope.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21