Reputation: 35
For some odd reason, I am getting the "EXC_BREAKPOINT CODE=1" runtime exception whenever I run this code:
var positionX: CGFloat = CGFloat(UInt32(width) + arc4random_uniform(UInt32(self.frame.width - 2.0 * width)))
Can someone tell me why this is? I am at a loss with how to fix this.
Upvotes: 1
Views: 378
Reputation: 919
The issue could be self.frame.width
- width
could be a negative number which will try to cast to UInt32
which will break. You may want to debug those 2 values and check before force casting to UInt32
. There could also be a problem with whatever property/parameter is applied to the result of this formula.
Also, if just width was a negative number the UInt32(width)
would fail as well.
Upvotes: 1