Post

Replies

Boosts

Views

Activity

Reply to MKMapView: How do I set mapType? (beginner question)
But everything returns an error... Can any one help me, please?  Where can I find an explanation of swift syntax? A few more comments: when you have error, please post the error what you tried: let map = MKMapView(.mapType = .hybridFlyover ) is a wrong syntax, as you have noticed. When you call a class initialiser that has parameters, it would be something like this syntax: let map = MKMapView(mapType: .hybridFlyover) No dot before the label for the parameter no equal but colon sign But this does not work here because no such initialiser exist (you could subclass MKMapView and create such a convenience init) This works: import MapKit class MyOwnMKMapView : MKMapView { convenience init(mapType: MKMapType) { self.init() self.mapType = mapType } } class KMLViewerViewController: UIViewController, MKMapViewDelegate { let map = MyOwnMKMapView(mapType : .hybridFlyover ) // You use your subclass // etc. ... }
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Having strange trouble with touchesMoved, need help.
OK, now we get the screenshots. But some explanation of what each picture is would help. Also some questions on your code: override func touchesMoved(_ touches: SetUITouch, with event: UIEvent?){ super.touchesMoved(touches , with:event) guard touches.first != nil else { return } if toggleHigh {highliteGem(theGem: myGems[0], clearAll: true)} if let touch = touches.first, let node = myGV.currentGem, node.isMoving == true { let touchLocation = touch.location(in: self) node.moved = true print(touchLocation) node.position = touchLocation node.isMoving = true node.inSlot = false //addTrailToTwinkle(theNode: node) } } In which class is this ? ie, what is self ? do we see effect of toggleHeight in the pictures of the gif ? line 10: we get there only when isMoving. So what the need ? what is the result of the print ? Is it what you expect ?
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to iPhone IDE
Developing on iPhone ? With the screen size. It is already hard on a 15" Macbook… I fear you are dreaming here. Did you see how huge and complex XCode is ? 10 GB code… And how frequently it has to update to cope with the OSes evolutions. So you'd better see how to best use XCode as it is and ask for improvements through Feedback assistant.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’21
Reply to Change localization of UIDatePicker in iOS 14
Thanks for feedback, I was sure it did work… As it is not possible to edit message, I duplicate the answer. You can change localization on the fly without restarting (works only over iOS 13.) You should do it by opening the app settings and let user select the language for the app: func openSettings() { guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return } if UIApplication.shared.canOpenURL(settingsUrl) { UIApplication.shared.open(settingsUrl, completionHandler: nil) // { (success) in } }
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’21
Reply to Most wanted Xcode features…
Wanted Feature : Get practical way to update an old project to open in recent version of Xcode. Pain point:  When trying to open an old project with a recent version of Xcode, one get a message to update from Swift x - Swift y, using and older Xcode. Problem is that the needed old Xcode may not run with the MacOS version. I noted in several occasions, that I just needed to set the version of Swift in project Build settings 'Swift Language version' from unknown to Swift 5 for instance. Then on opening, automatic conversion was proposed, without need to launch ancestral version of Xcode. Feasibility: Simply a need for better message and advice.
May ’21
Reply to Most wanted Xcode features…
Wanted Feature : Get better information about incompatibility between XCode and device. Pain point: Frequent question on the forum about compatibility of such version of Xcode with a version of iOS on attached device. This highlights that alert message from Xcode should provide more precise and helpful information about the incompatibility. Feasibility: Simply a need for more explicit message.
May ’21
Reply to Seeking App to Lock Phone
Lock is a system function, I don't think that could be done. And imagine the risk: some app you download locks your iPhone until you pay something… But there is a solution. Ask someone to change your password and you'll be forced to ask him/her to unlock. This person will 'set the human timer'. Good luck and desintox. Don't forget to close the thread by marking the correct answer before you shut down the Mac as well for some time.
Topic: App & System Services SubTopic: Core OS Tags:
May ’21
Reply to How do I properly use class variables?
Class names should start by uppercase. define a class variable in foo Do you mean a static var or just a property in class ? Is this what you look for ? : class Foo { static var staticValue: Int = 0 var value: Int = 0 } class Bar: Foo { convenience init(with initValue: Int) { self.init() self.value = initValue } } print("Bar.staticValue", Bar.staticValue) let bar = Bar(with: 3) print("bar.value", bar.value) You get: Bar.staticValue 0 bar.value 3
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to Build an app by Swift Playgrounds
What is your question precisely ? There are already a lot of family tree apps, they will show you what they are exactly. Did you search on the web ? http ://en.wikipedia. org/wiki/Family_tree If you are a beginner, take care, that is a complex app, which requires a good knowledge of Swift. Don't forget to close your threads when you get the answer you need, by marking the correct answer.
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to MKMapView: How do I set mapType? (beginner question)
But everything returns an error... Can any one help me, please?  Where can I find an explanation of swift syntax? A few more comments: when you have error, please post the error what you tried: let map = MKMapView(.mapType = .hybridFlyover ) is a wrong syntax, as you have noticed. When you call a class initialiser that has parameters, it would be something like this syntax: let map = MKMapView(mapType: .hybridFlyover) No dot before the label for the parameter no equal but colon sign But this does not work here because no such initialiser exist (you could subclass MKMapView and create such a convenience init) This works: import MapKit class MyOwnMKMapView : MKMapView { convenience init(mapType: MKMapType) { self.init() self.mapType = mapType } } class KMLViewerViewController: UIViewController, MKMapViewDelegate { let map = MyOwnMKMapView(mapType : .hybridFlyover ) // You use your subclass // etc. ... }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Having strange trouble with touchesMoved, need help.
OK, now we get the screenshots. But some explanation of what each picture is would help. Also some questions on your code: override func touchesMoved(_ touches: SetUITouch, with event: UIEvent?){ super.touchesMoved(touches , with:event) guard touches.first != nil else { return } if toggleHigh {highliteGem(theGem: myGems[0], clearAll: true)} if let touch = touches.first, let node = myGV.currentGem, node.isMoving == true { let touchLocation = touch.location(in: self) node.moved = true print(touchLocation) node.position = touchLocation node.isMoving = true node.inSlot = false //addTrailToTwinkle(theNode: node) } } In which class is this ? ie, what is self ? do we see effect of toggleHeight in the pictures of the gif ? line 10: we get there only when isMoving. So what the need ? what is the result of the print ? Is it what you expect ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to iPhone IDE
Developing on iPhone ? With the screen size. It is already hard on a 15" Macbook… I fear you are dreaming here. Did you see how huge and complex XCode is ? 10 GB code… And how frequently it has to update to cope with the OSes evolutions. So you'd better see how to best use XCode as it is and ask for improvements through Feedback assistant.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Change localization of UIDatePicker in iOS 14
I tested on 12.4 and 14.4. With this code I land in Settings page for the app, with Preferred language entry to select. So I cannot tell for sure on 12.5, but I'm surprised. Have you a way to compare on 12.4 and 14.4 ?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Change localization of UIDatePicker in iOS 14
Thanks for feedback, I was sure it did work… As it is not possible to edit message, I duplicate the answer. You can change localization on the fly without restarting (works only over iOS 13.) You should do it by opening the app settings and let user select the language for the app: func openSettings() { guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return } if UIApplication.shared.canOpenURL(settingsUrl) { UIApplication.shared.open(settingsUrl, completionHandler: nil) // { (success) in } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Apple Fitness - Change what value gets shown in the Workouts List
Hope this limited tip may help. there is at least one 3rd party app whose saved workouts actually show the KCAL in the Fitness App's overview Did you try to contact them, and directly ask them ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Update iOS and iPhone does not recognised in Xcode now
Did you try to remove teh iphone from registered devices in XCode and re-register ?
Replies
Boosts
Views
Activity
May ’21
Reply to Most wanted Xcode features…
Wanted Feature : Get practical way to update an old project to open in recent version of Xcode. Pain point:  When trying to open an old project with a recent version of Xcode, one get a message to update from Swift x - Swift y, using and older Xcode. Problem is that the needed old Xcode may not run with the MacOS version. I noted in several occasions, that I just needed to set the version of Swift in project Build settings 'Swift Language version' from unknown to Swift 5 for instance. Then on opening, automatic conversion was proposed, without need to launch ancestral version of Xcode. Feasibility: Simply a need for better message and advice.
Replies
Boosts
Views
Activity
May ’21
Reply to Most wanted Xcode features…
Wanted Feature : Get better information about incompatibility between XCode and device. Pain point: Frequent question on the forum about compatibility of such version of Xcode with a version of iOS on attached device. This highlights that alert message from Xcode should provide more precise and helpful information about the incompatibility. Feasibility: Simply a need for more explicit message.
Replies
Boosts
Views
Activity
May ’21
Reply to Seeking App to Lock Phone
Lock is a system function, I don't think that could be done. And imagine the risk: some app you download locks your iPhone until you pay something… But there is a solution. Ask someone to change your password and you'll be forced to ask him/her to unlock. This person will 'set the human timer'. Good luck and desintox. Don't forget to close the thread by marking the correct answer before you shut down the Mac as well for some time.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to UIPickerView button not worked
Who is self here ? Could you show more code ? I guess that removing the animation would solve the problem, but that's not a perfect solution.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Swift student challenge
What is your question ? Do you look for an idea for the challenge ? Look around you to get ideas. For instance: learning app to recognize flowers, with a quizz that shows photos and ask to recognize
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to How do I properly use class variables?
Class names should start by uppercase. define a class variable in foo Do you mean a static var or just a property in class ? Is this what you look for ? : class Foo { static var staticValue: Int = 0 var value: Int = 0 } class Bar: Foo { convenience init(with initValue: Int) { self.init() self.value = initValue } } print("Bar.staticValue", Bar.staticValue) let bar = Bar(with: 3) print("bar.value", bar.value) You get: Bar.staticValue 0 bar.value 3
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Why is this crashing?
There are many test if IconChange.setIconPurchased == true { Which one is not triggered ? Note: you could simply write: if IconChange.setIconPurchased {
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to Build an app by Swift Playgrounds
What is your question precisely ? There are already a lot of family tree apps, they will show you what they are exactly. Did you search on the web ? http ://en.wikipedia. org/wiki/Family_tree If you are a beginner, take care, that is a complex app, which requires a good knowledge of Swift. Don't forget to close your threads when you get the answer you need, by marking the correct answer.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21