Jake2Finn Jake2Finn - 4 months ago 27
iOS Question

update an array of tuples with certain index

I am stuck trying to update my multidimensional array. First, I filter for a certain string called title, which serves as my identifier. Then I want to replace the value for description for this filtered array.

I have already tried to solve this issue with something like

rowContent[1] = descriptionTranferred
(value at index 1, which is description, shall be replaced by value in descriptionTranferred). I also tried
rowContent.description = descriptionTranferred
, but it was not successful either.

Is there any way to update the description value in my array?

Here is my code:


var rowContent = Array<(title: String, description: String)>()

func transferData(descriptionTranferred: String, identifier: String)
if rowContent.contains(where: {$0.title == identifier}) {

rowContent[1] = descriptionTranferred

} else {
print ("nothing")


It's not a multidimensional array but array of tuples with named parameters. Try:

rowContent[1].description = descriptionTranferred

But I'm guessing that you're trying to change description in tuple on index that matches identifier so replace your if condition:

if let index = rowContent.index(where: {$0.title == identifier}) {
    rowContent[index].description = descriptionTranferred
}else {
    print ("nothing")