I'm not sure if you want to add/multiple numbers in both array. And not sure what do you want to calculate from two arrays. So I've added example code below to add and multiple two string arrays.
func calculateTwoArrays(){
let array1 = ["1", "1"]
let array2 = ["£129.95", "£129.95"]
//Add all values together
var total:Double = 0.0
for value in array1 {
if let number = Double(value.replacingOccurrences(of: "£", with: "")){
total += number
}
}
print("Total:(total)")
//Multiply array values, assuming array1 as quantity and array 2 as price.
var priceArray = [Double]()
for quantity in array1 {
for price in array2 {
if let quantityValue = Double(quantity), let priceValue = Double(price.replacingOccurrences(of: "£", with: "")){
priceArray.append(quantityValue*priceValue)
}
}
}
total = priceArray.reduce(0, +)
print("Total:(total)")
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…