Post

Replies

Boosts

Views

Activity

Reply to Array Elements - Getting Control
Thanks for your constructive input. Now don't you worry about my issue ok. I'm sure things will work out fine. A solution will present itself oneway or another. p.s - data was used in this context : "@Binding var data: DataModel" - an 'Identifiable data struct' ..
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
Reply to Array Elements - Getting Control
Without reiterating, let's assume that data is a generic name I used to represent the conceptual approach I was taking. Unfortunately, as you say I can't edit the post, and where I refered to the ForEach method I incorrectly typed 'array' which should of been 'arr', once again conceptual representation. Ultimately the question in it's simplest form is: Can I increment a value with each loop of the ForEach method? If so, How?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
Reply to Array Elements - Getting Control
I want to use the method 'ForEach(data.arr[0], id: \.self { item in' to take advantage of the .onDelete { indices in method Im pretty sure onDelete is refering to indices that were communicated by the ForEach method using another ForEach method ie ForEach(data.arr[0] { i in is great in terms of identifying the indexes, except it breaks the onDelete method So I was thinking I could just throw a counter in to the forEach method, because I'm still becoming familiar with Swifts architecture to be honest I have no Idea how to simply apply that concept. private var index: Int = 0 ForEach(data.array[0], id: \.self) { item in index += 1 TextField("FieldName", text: $data.arr[0][index][0]) CheckBoxFromString(isSetString: $data.arr[0][index][2]) but it seems it's not approachable in this way because it creates a conflict for the 'View' class i need to correctly identify the index so I can apply binding to it $data.arr[0][index][0] The following methods require binding in order to operate a) TextField() b) CheckBoxFromString() Is that a bit clearer?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21