swift - Cannot find overload for '/', '*', Failure when running an app on anything but iPhone 5s simulator -
swift - Cannot find overload for '/', '*', Failure when running an app on anything but iPhone 5s simulator -
my game builds , runs on iphone 5s simulator, when seek on other version next 2 errors:
`could not find overload '*' accepts supplied arguments` `could not find overload '/' accepts supplied arguments`
i'm writing game exclusively in swift, , deployment target ios 7.1
the die rolls in image defined as
let lengthdiceroll = double(arc4random()) / 0x100000000 allow sidediceroll = int(arc4random_uniform(uint32(4)))
your problem difference between 32- , 64-bit architecture. note target architecture you're compiling target determined selected device—if you've got iphone 4s simulator selected target in xcode, example, you'll building 32 bit; if you've got iphone 5s simulator selected, you'll building 64-bit.
you haven't included plenty code help figure out going on (we'd need know types of variable you're assigning to) here's theory. in first error, sprite.speed cgfloat. cgfloat 32-bit ("float") on 32-bit targets, 64-bit ("double") on 64-bit targets. this, example:
var x:cgfloat = double(arc4random()) / 0x100000000
...will compile fine on 64-bit target, because you're putting double double. when compiling 32-bit target, it'll give error you're getting, because you're losing precision trying stuff double float.
this work on both:
var x:cgfloat = cgfloat(arc4random()) / 0x100000000
your other errors caused same issue (though again, can't reproduce them accurately without knowing type you've declared width
, height
as.) example, fail compile 32-bit architecture:
allow lengthdiceroll = double(arc4random()) / 0x100000000 allow width:cgfloat = 5 var y:cgpoint = cgpointmake(width * lengthdiceroll, 0)
...because lengthdiceroll double, width * lengthdiceroll
double. cgpointmake takes cgfloat arguments, you're trying stuff double (64-bit) float (32-bit.)
this compile on both architectures:
allow lengthdiceroll = double(arc4random()) / 0x100000000 allow width:cgfloat = 5 var y:cgpoint = cgpointmake(width * cgfloat(lengthdiceroll), 0)
...or perchance better, declare lengthdiceroll cgfloat in first place. won't accurate on 32-bit architectures, that's sort of point of cgfloat:
allow lengthdiceroll = cgfloat(arc4random()) / 0x100000000 allow width:cgfloat = 5 var y:cgpoint = cgpointmake(width * lengthdiceroll, 0)
ios-simulator swift xcode6
Comments
Post a Comment