Reputation: 366
I have been working on a project and everything seemed to work fine. I have added the following class extension:
extension CGFloat {
static func random() -> CGFloat {
return CGFloat(Float(arc4random()) / Float(UInt32.max))
}
static func random(#min: CGFloat, max: CGFloat) -> CGFloat {
assert(min < max)
return CGFloat.random() * (max - min) + min
}
}
And I suddenly got 21 errors. The screen shot is below.
Anyone knows how to solve this?
EDIT:
I managed to solve the problem, which apparently was that I should import UIKit above everything else. Now I still have a problem, that the app runs fine on a simulator but does not work on real device. It says that there is segmentation fault: 11, and that it cant build obj-c module UIKit.
Upvotes: 0
Views: 178
Reputation: 366
Ok I managed to solve it: All I needed to do was to reduce my deployment target from 8.3 to 8. No idea why this is the case though.
Upvotes: 0
Reputation: 2724
In the case adding UIKit started making things work. Could it be as simple as adding...
import Foundation
on the top would make it work?
Upvotes: 1