Reputation: 2776
I am using Swift, and I am trying to use the += assignment operator, but I am getting this error. Here is my code:
var total = NSNumber.numberWithDouble(0.00)
for exercise in exercises {
total += exercise.duration
}
return total
the duration property of the exercise object is a NSNumber, so I don't see why I am not able to perform the assignment. Does anyone know why this is not working?
Upvotes: 0
Views: 191
Reputation: 41831
NSNumber doesn't have a += operator. I would suggest using Double instead, then converting to NSNumber after the loop if you really need an NSNumber.
Upvotes: 3