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
extension UILabel { | |
func textWidth() -> CGFloat { | |
return UILabel.textWidth(label: self) | |
} | |
class func textWidth(label: UILabel) -> CGFloat { | |
return textWidth(label: label, text: label.text!) | |
} | |
class func textWidth(label: UILabel, text: String) -> CGFloat { |
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
// Swift version of the code from http://stackoverflow.com/a/30335594/1986600 | |
import CoreTelephony | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
let isCapableToCall: Bool | |
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "tel://")!) { | |
// Check if iOS Device supports phone calls |
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
func validate(response: HTTPResponse, forRequest request: HTTPRequest) -> HTTPResponseValidatorResult { | |
if !(200..<300).contains(response.statusCode) { | |
// invalid response, we want to fail the request with error | |
throw HTTPError.invalidResponse | |
} | |
return .nextValidator // everything is okay, move to next validator | |
} |