This is a companion discussion topic for the original entry at https://www.raywenderlich.com/17493408-your-first-ios-and-swiftui-app-an-app-from-scratch/lessons/4
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/17493408-your-first-ios-and-swiftui-app-an-app-from-scratch/lessons/4
How do you post a question. Sorry an absolute beginner. Wondering in the tutorial how you move buttons or even delete them etc.
In XCode 12.5, cannot use Slider(value: .constant(70), in: 1.0...100.0)
directly, should use Slider(value: .constant(70.0), in: 1.0...100.0)
.
Thanks for the comment @zhongdongy! I struggled with this a bit and noticed the same behaviour with the latest XCode.
Hi @zhongdongy I have the same problem
Failed to build ContentView.swift
Compiling failed: cannot convert value of type โintโ to expected argument type โDoubleโ
Can any one help ?
Regards
Paul
Hi Paul,
If you have the compiling issue for converting โIntโ to โDoubleโ, as long as you are trying to put a numeric literal (like 20
), you can change to something like 20.0
. But if you are using a variable, you might need to change the declaration of that or use type cast: Double(your_int_var)
.
For more information, you may refer to the document: The Basics โ The Swift Programming Language (Swift 5.4) and look for this section: Integer and Floating-Point Conversion.
Regards,
David
Hi David
Thanks for your help , that has solved the problem
Slider(value: .constant(50.0), in: 1.0โฆ100.0)
The preview in the canvas now works great.
Regards
Paul
Thank you so much
I have compiling issue
I got it!
Thanks Brother. You saved my day.