Post

Replies

Boosts

Views

Activity

Reply to Checking the contents of a TextField variable method not working
Thank you again but yet again out of my depth! Having said that I feel I have learned so much from your help! I am thinking when my head stops spinning I will compare the difference/s between how you have constructed this Form and how I have in my App. I already know your way has far less need for Variables. PS I added ScrollView to make the View scrollable. var body: some View { ScrollView(.vertical, showsIndicators: false) { VStack { ForEach(cards, id: \.self) { card in VStack { Divider() TextEntryView_PartOne(card: card) Divider() CoordEntryView(isLatitude: true, card: card) Divider() CoordEntryView(isLatitude: false, card: card) Divider() TextEntryView_PartTwo(card: card) Divider() } .padding() } } } .padding() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’25
Reply to Checking the contents of a TextField variable method not working
Thanks again for your help with this. Although I have not used your solution exactly it did help me a great deal to construct a solution (example enclosed). Still working on these examples of input error… -.234567 (If (Left of “.”) contains “-“ then the length of (Left of “.” ) minimum = 2). 1-2.123456 (If (Left of “.”) contains “-“ it should be the first character. I understand your solution is far better because it reduces the amount of code etc. but I am not ready to rebuild my app from the ground-up yet. I need to learn and understand Swift alot more before I tackle that. // In this example “coordinate” is either Latitude or Longitude // Error example = 00.000000 // If coordinate contains more than one “-“ if(coordinate.filter( { $0 == "-" } ).count > 1) { coordinate = "00.000000" // Reset coordinate } // If coordinate contains more than one “.“ if(coordinate.filter( { $0 == "." } ).count != 1) { coordinate = "00.000000" // Reset coordinate } // If coordinate contains an illegal character // Get coordinate length before check let coordinateLengthBefore = coordinate.count let validCharsCoordinate: Set<Character> = ["-", ".", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] // Allowed characters // Remove characters not in Character Set coordinate.removeAll(where: { !validCharsCoordinate.contains($0) } ) // Get coordinate length after check let coordinateLengthAfter = coordinate.count // If coordinate length is different due to illegal character removal if coordinateLengthBefore != coordinateLengthAfter { coordinate = "00.000000" // Reset coordinate } // Check each side of the "." // Check coordinate before the "." let coordinateStr = coordinate let coordinateCh = Character(".") let coordinateResult = coordinateStr.split(separator: coordinateCh).map { String($0) } let coordinateLeftSplit = coordinateResult[0] let coordinateLeftCount = coordinateLeftSplit.count if coordinateLeftCount >= 4 { // More than 3 characters before "." cards.firstCardLatitude = "00.000000" // Reset coordinate } // Check coordinate after the "." let coordinateRightSplit = coordinateResult[1] if(coordinateRightSplit.filter( { $0 == "-" } ).count > 0) { coordinate = "00.000000" // Reset coordinate ("-" not allowed) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’25
Reply to Clearing an app’s memory, data etc.
Thank you for taking your time to help with this. I have tried your suggestion but I probably need to stress that the app does not crash but just has a problem of a random current View disappearing to show the previous View that contains a Button that opened it. In my app I made sure that after each round a user has to start from the beginning again. This is where I was hoping to do a reset. From my investigations I know you are not allowed to force quit an app programmaticall. I also understand my app is overweight so maybe I need to wait until I redo it starting with what I have learnt from you.
Topic: Community SubTopic: Apple Developers Tags:
May ’25