Cannot use "floor" in swift

Use round(_:) method or rounded(_:)

round(_:)]: Rounds the value to an integral value using the specified rounding rule. rounded(_:): Returns this value rounded to an integral value using the specified rounding rule

var w1 = 6.5
w1.round()
// w1 == 7.0

// Equivalent to the C 'round' function:
var w = 6.5
w.round(.toNearestOrAwayFromZero)
// w == 7.0

// Equivalent to the C 'trunc' function:
var x = 6.5
x.round(.towardZero)
// x == 6.0

// Equivalent to the C 'ceil' function:
var y = 6.5
y.round(.up)
// y == 7.0

// Equivalent to the C 'floor' function:
var z = 6.5
z.round(.down)
// z == 6.0

floor takes a Double and returns another Double. If you want it to be an Int (to match self.maxViewers, you must convert it explicitly: Int(floor(viewSize / itemSize)).

Tags:

Ios

Swift