Malthe Pedersen Malthe Pedersen - 6 months ago 13x
Swift Question

Cannot divide two NSNumbers in swift?

I have two NSNumbers that I want to divide, but in the last line of the code I get the error: "Cannot invoke '/' with an argument list of type '(@Ivalue NSNumber,@Ivalue NSNumber)'"

var firstnumber: NSNumber = object["numberone"] as NSNumber
var secondnumber: NSNumber = object["numbertwo"] as NSNumber
var calculated: NSNumber = firstnumber / secondnumber

Can anyone help me with this??


NSNumber is an object which holds a value that can be retreived as different types by using its properties such as floatValue, integerValue and so on. NSNumber

So by doing nsnumber1 / nsnumber2 would be like doing uiview1 / uiview2