I'm building a budget app in Swift.
The NSDecimalNumber is first added to an array after an action (below).
Then the NSDecimalNumber is converted to CurrencyFormat for TableView, and appended to a separate string array.
How can I find the sum of the first NSDecimalNumbers array to create an Available Amount Label?
var adding: [NSDecimalNumber] = [5, 6, 5.55, 6.55, 1]
I tried this to convert the number into NSDecimal(addingAmount), and then append it to the above array (adding):
let addingAmount = NSDecimalNumber(string: textInput.text) / decimal100
adding.append(addingAmount)
println(adding)
println(reduce(adding, 0, +)) // prints 15
Unfortunately, println(adding) works, but nothing is printed for the sum.
Any help would be appreciated, thanks.