I'm fairly new to Swift and I'm sure this is a relatively straight forward question. I have a nested for loop and I would like to break out of the inner loops after appending the data to an array. Below is my code:
for set in self.setArray{
self.itemData = "Set "
self.itemData += set
self.itemData += " "
for reps in self.repsArray{
self.itemData += reps
self.itemData += " Reps "
for weight in self.weightArray{
self.itemData += "Weight "
self.itemData += weight
self.itemData += "kg"
structSetArray.append(self.itemData)
self.itemData = ""
break
}
break
}
}
Currently the break statements allow me to return back to the set array and retrieve the next item, however, this causes the reps and weight arrays to start from the beginning again. How can I prevent this from happening so all the loops retrieve the second item?
Thanks in advance