String(describing: type(of: <#Class#>))extension URL {
func valueOf(_ queryParamaterName: String) -> String? {
guard let url = URLComponents(string: self.absoluteString) else { return nil }
return url.queryItems?.first(where: { $0.name == queryParamaterName })?.value
}
}guard !isEmpty, let firstChar = first else { return false }
return String(firstChar).range(of: ".*[^A-Za-z0-9].*", options: .regularExpression) != nilenum Deeplink {
case home
case videos(Video)
case preferences
func associatedViewController() -> AnyClass {
switch self {
case .home:
return KidsHomeViewController.self
case .videos(_):
return KidsVideoViewController.self
case .preferences:
return KidsPreferenceViewController.self
}
}
}
// Somewhere else
if myViewController.classForCoder == deeplink.associatedViewController() {
// Some code
}extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
} if let filepath = Bundle.main.path(forResource: "xyz", ofType: "json") {
do {
let contents = try String(contentsOfFile: filepath)
let xyz = fromJSON(contents)
return xyz as! TenantFile
} catch {
fatalError()
}
} else {
fatalError()
}