In case this highlights the issue, here is the source code for Objective-C.
int x = (arc4random()%(int)(self.gameView.bounds.size.width*5)) - (int)self.gameView.bounds.size.width*2; int y = self.gameView.bounds.size.height; drop.center = CGPointMake(x, -y);
I started with this code. Lines 2 and 3 are fine, I will introduce them for clarity later.
let x = CGFloat(arc4random_uniform(UInt32(self.gameView.bounds.size.width * 5))) - self.gameView.bounds.size.width * 2 let y = self.gameView.bounds.size.height dropView.center = CGPointMake(x, -y)
In Xcode 6 beta 3, it was necessary to output the result of arc4random_uniform UInt32 to CGFloat so that minus and multiplication work. This no longer works and the compiler shows an error:
'CGFloat does not convert to' UInt8
The release notes indicate:
"CGFloat is now a separate floating point type that wraps either Float on 32-bit architectures or Double on 64-bit architectures. It provides all the same operations of comparison and arithmetic of Float and Double and can be created using numeric literals. CGFloat isolates your code from situations where your code will be! Great for 32-bit, but doesn’t work when creating for 64-bit, or vice versa. (17224725) "
Am I just doing something wrong with types? I don’t even know how to best describe this problem in order to report an error in Apple for beta 4. Almost every Swift project that I have, does any kind of dot problem or direct manipulation, got into this problem, so I looking for some sanity.
type-conversion operator-overloading xcode swift cs193p
kasplat Jul 21 '14 at 19:33 2014-07-21 19:33
source share