This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func formatAsCurrencyString(value: NSNumber?) -> String? { | |
let formatter = NumberFormatter() | |
formatter.locale = Locale(identifier: "en_US") | |
formatter.numberStyle = .currency | |
// TODO: Unwrap the number as a formatted currency String | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard let value = value, | |
let formattedCurrencyAmount = formatter.string(from: value) else { | |
return nil | |
} | |
return formattedCurrencyAmount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard let apiURL = apiURL else { | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
makeValueGETRequest(url: apiURL) { (value) in | |
DispatchQueue.main.async { | |
self.etherValueLabel.text = self.formatAsCurrencyString(value: value) ?? "Failed" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc enum ScreenType: Int { | |
case iPhone4, iPhone5, iPhone6, iPhone6Plus, iPhoneX, iPad9_7, iPad10_5, iPad12_9 | |
} | |
extension UIScreen { | |
@objc static var current: ScreenType { | |
let screenLongestSide: CGFloat = { | |
let screenBounds = main.bounds | |
if screenBounds.height > screenBounds.width { | |
return screenBounds.height |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if UIScreen.current == .iPhone5_8 { | |
print("Screen type is iPhone X") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if UIScreen.current == .iPhone4_7 || UIScreen.current == .iPhone5_5 { | |
print("Screen type is either iPhone 6/7/8 or 6/7/8 Plus") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if UIScreen.current < .iPhone4_7 { | |
print("Screen is smaller than an iPhone 6/7/8") | |
} | |
if UIScreen.current >= .iPad10_5 { | |
print("Screen type is either iPad 10.5 or iPad 12.9") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([UIScreen current] == ScreenTypeIPhone5_8) { | |
NSLog(@"Screen Type is iPhone X"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([UIScreen current] > ScreenTypeIPhone4_0) { | |
NSLog(@"Screen is larger than an iPhone 5/5S/5C"); | |
} |