How would it be possible in swift to pair number with the same index? as you have seen in the code below there were 2 set of array . when code runs i want to assign first index of devices to lbNum1.text and first index of devices1 to lbNum2.text and then next would be next index and so on.for example lbNum1.text = 1 and lbNum2.text = 2 and it will set random again to lbNum1.text = 2 and lbNum2.text = 3 until in reach to the end
code
lbNum1.text = String(randomItem)
lbNum2.text = String(randomItem1)
//the value of this 2 must be with the same index lbnum1 will ge data from device and lbnum 2 will get the from device1
they shoudl get data from the same index
let devices = [1, 2, 8, 7, 6]
let randomIndex = Int(arc4random_uniform(UInt32(devices.count)))
let randomItem = devices[randomIndex]
print("random item:" ,randomItem)
let devices1 = [2, 3, 2, 9, 3]
let randomIndex1 = Int(arc4random_uniform(UInt32(devices1.count)))
let randomItem1 = devices[randomIndex1]
print("random item:" ,randomItem)
Aucun commentaire:
Enregistrer un commentaire