Post

Replies

Boosts

Views

Activity

SwiftUI help with application of multiple radio buttons to perform calculations based on selected option
I am making this calculator where one option would be selected for each radio button, the question is how to implement code to perform calculation depending on each option. I ma newbie and was able to finally make these multiple radio buttons on screen that grouped together. For example, if height is in inches, need to first change height to cams, and considering following code, but unable to `        var heightCms: Double = 0.0                  if (heightRadioButtonGroups(callback: heightRadioInchesMajority).isSelected) {             return Double(height) ?? 1 * 2.54         } else {             return Double(height) ?? 1         } */ Though heightRadioInchesMajority is within the code, but getting error that is out of scope. Would appreciate a simplified solution. In Android Kotlin, it was easy and was able to do it quickly, but here finding difficult and most of online videos are using Ukit or older versions and not much on swiftUI. In the code shows I used 1 for default value but doesn't matter if it is 0 or 1. I used 1, so that multiplying with zero results in 0 but with 1 will give same value. Thank
9
0
1.2k
Sep ’21
Calculations using picker options in swiftUI
I have to do multiple calculations using one of the two options of units using picker in swiftUI. I am unable to complete the calculations, The code for one variable is below struct ContentView: View {          @State var height = ""         @State var heightCms: Double = 0.0          var heightOptions = ["cms", "inches"]     @State private var heightselection = "cms"          var body: some View {         VStack {             HStack {                 Text("Height:")                     .font(.title)                     .foregroundColor(.black)                 Spacer()                                  TextField("Height", text: $height)                     .frame(width: 150, height: 50)                                  Picker("Select Height Units: ", selection: $heightselection, content: {                     ForEach(heightOptions, id: \.self) {                         Text($0)                     }                 })                                  Spacer()             }             Text("You selected: \(heightselection)")                      Text("Height in Cms: \(heightCms)")                                }.padding()                  } }          struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } extension ContentView {     func calculate() {      heightCms = heightselection == "cms" ? String(Double(height)) : (String(Double(height)) * 2.54)     } } Would appreciate help in completing the task and understanding the error. The code provide correct selection answer but when try to apply in calculation then it doesn't work
2
0
996
Oct ’21
having difficult time with uploading archive to app connect from Xcode
I am a newbie, made an app using Flutter (in VSCode on MacBook Air) - for iOS and testing the app works well, and trying now to upload the app as directed on App Connect. I registered the App with relevant information and images both for iPhone and iPAD, and then prepared the iOS release - using flutter clean and then flutter build iOS --release actions in Terminal. Following that as directed, opened iOS tab in VSCode, in Xcode (by right clicking and opening Xcode, and then made Archive file and it succeeded. Up to this level everything worked but the archive file is named as Runner (and not with the AppName - CFDisplayName in P.list and similarly the bundle ID is not as in the system and defaults to com.example.appName, and when I try to validate this file in Xcode, then able to correct name but can not change Bundle ID, and it remains as com.example.appName, and no matter what I do, the same error, "App Record Creation failed due to request containing an attribute already in use. The App Name you entered is already being used. If you have trademark rights to this name and would like it released for your use, submit a claim." I can not delete the info I submitted on App connect site, and it gives an error it can not be deleted, as is use in App Store, when I have not submitted the App, only saved pertinent information and images on website. I think I should n't have entered the app connect site first to register the app, and possibly let Xcode to validate and register app on app connect by default. This is the first time I am trying to use the system, and would appreciate any help to correct this issue. Thank you. atbeat
0
0
460
Aug ’24