1: you cannot drag from Int to CGFloat. You must initialize CGFloat with Int as an input.
return CGFloat(screenHeight) / CGFloat(cellCount)
2: Use the min and max functions defined by the standard library. They are defined as follows:
func min<T : Comparable>(x: T, y: T, rest: T...) -> T func max<T : Comparable>(x: T, y: T, rest: T...) -> T
Usage is as follows.
let lower = min(17, 42) // 17 let upper = max(17, 42) // 42
Mick MacCallum Jun 13 '14 at 9:27 a.m. 2014-06-13 09:27
source share