Post

Replies

Boosts

Views

Activity

Comment on very weird swiftui button behavior
But I can't figure out how to init gridCellArr like that. So: @State var gridCellArr = buildCellArray(theGridSize: 3) works @State var gridCellArr = buildCellArray(theGridSize: boardSize) does not because using before init. I tried initially doing @State var gridCellArr: [Cell], and then: init() { gridCellArr = buildCellArray(theGridSize: _boardSize.wrappedValue) } but as soon as I change the value for boardSize in the picker, BOOM.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Comment on very weird swiftui button behavior
that's working. here's what I'm seeing now. If I set the initial board size as a state var and pass it an integer like 3, I get a 3x3 grid, everything works fine including the button state. however, that creates a different problem in that in my "main" game, there's a picker that lets you set a gridSize between 3x3 and 10x10, so it changes boardSize right? from 3 to 10, but if I'm hardcoding the board size when I init gridCellArr, changing boardsize causes index out of range errors.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Comment on very weird swiftui button behavior
yes, it does. That's part of what's weird. It compiles and it even mostly runs until i try to set buttonBlank. if I move it up with the rest of the @state vars, then the weird behavior goes away, but I have to use an actual integer to init gridCellArr, and then I can't resize the grid. So that's replacing one problem with another.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23
Comment on How to increment an integer in a ForEach loop
@Claude31 okay, so because I'm having such a hard time: i have an enum with three states: blank, s, o (myEnum) I then have a @state var myEnumArray = [myEnum] in an onTapGesture, I pass the current location and do whatever to the cell state, and return that new cell state That I think I get what I'm not getting is how to have button A check the state of button D. that's the part that's been running away from me like an ice cream truck driven by a sadist.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’23