Answer the question
In order to leave comments, you need to log in
How to change the value of an array which is the elements of another array in swift 5?
I have an array that is initialized from JSON:
var someArray = json as! Array<Any>
This is an array of arrays
(someArray[i] as! Array<Any>)[j] = "some value"
but an error comes up saying that I cannot change the elements of an immutable array, although the elements of the original array are changed:
someArray[i] = someAnotherArray
How can I change the value of an array that is the elements of another mutable array?
Answer the question
In order to leave comments, you need to log in
It is necessary someArray[i]
to assign the variable var A1. Update A1[j]. Assign A1 to someArray[i]
.
If this is an array of arrays, then you need to make an array of arrays from it:
var someArray = json as!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question