Reputation: 2184
After updating Swift to 2.0 I need to fix my code. Automatic correction doesn't work.
func getValueForKey(key: String) -> CGFloat {
var inch = ""
if screenSize.height == 480 {
// iPhone 4, 4s and below
inch = "3.5"
} else if screenSize.height == 568 {
// iPhone 5, 5s
inch = "4"
} else if screenSize.width == 375 {
// iPhone 6
inch = "4.7"
} else if screenSize.width == 414 {
// iPhone 6+
inch = "5.5"
} else if screenSize.width == 768 {
// iPad
inch = "5.5+"
}
let result = values["\(key)\(inch)"]!
// println("\(key) - \(result)")
return result
}
I have changed it. But nothing happens and it appears again!
How to fix it?
Upvotes: 1
Views: 427
Reputation: 42449
To elaborate on why importing UIKit
fixes this problem:
The CGFloat
struct is part of the CoreGraphics
framework. UIKit
by default imports Foundation
which imports CoreGraphics
.
If you weren't using UIKit
or were on a platform that doesn't have the UIKit
framework (such as Linux), Importing the Foundation
module will import CoreGraphics
.
Upvotes: 1
Reputation: 2184
The reason was absence of library UIKit.
import UIKit
This code before class has solved the problem.
Upvotes: 0