16
u/xylont Oct 11 '18
Did this happen?
39
Oct 11 '18
not exactly like this but Swift 4.2 has a heap of random functions, e.g.
Int.random(in: 0..<10)18
5
5
u/quellish Oct 11 '18
Depending on what you’re using them for the GameKit methods can be vastly superior.
11
u/lolcoderer Oct 11 '18
Now if that could only solve the stupid Double vs CGFloat crap.
I want to do this
var width = aDate.timeIntervalSince(anotherDate) * pixPerSec
let view = UIView(frame: CGRect(x:0, y:0, width: width, height: self.frame.height)Instead of this stupid crap:
var width = aDate.timeIntervalSince(anotherDate) * pixPerSec
let view = UIView(frame: CGRect(x:0, y:0, width: CGFloat(width), height: self.frame.height)6
u/ducusheKlihE Oct 11 '18
Just extend CGRect with a custom convenience initializer.
12
u/lolcoderer Oct 11 '18 edited Oct 11 '18
That isn't the problem and that would not help... There are already tons of CGRect initializers. There is a CGRect for CGFloat params and CGRect for Double params - the issue is that there are many places in my code (and I imagine this is widely observed by others as well) - I was just using TimeInterval here as an example where this could come up - where both Doubles and CGFloats are used whose values end up being assigned to Core Graphics properties.
Having to manually coerce a Double to CGFloat just to use it in place of a CGFloat is just silly - they are the same exact thing internally (on 64 bit systems) I believe.
My code is literally littered with casts of Doubles to CGFloats - and it feels so unnecessary.
2
u/DanielPhermous Oct 11 '18
Yeeess.... But I kind of needed to seed, so my appreciation was short lived. However, I did find a use for array.shuffle().
0
3
u/[deleted] Oct 12 '18
What does arc4 mean?