我有两个日期对象:
1: 2017-01-13 11:40:17 +0000
2: 2016-03-15 10:22:14 +0000
我需要比较这些值的时间并忽略日期
例如:上午12:00和上午12:01,晚上12:01(上午12:01>上午12:00)== true
extension UIViewController {
func getChildViewController<T>(OfType: T) {
let classType = Mirror(reflecting: self.childViewControllers.first).subjectType
if classType == T.self {
print("there is a match")
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是UIViewController的扩展,当您调用此函数时,可以将其传递为一种类型,例如:
ViewController.getChildViewController(OfType: SecondViewController.self)
Run Code Online (Sandbox Code Playgroud)
这将检查视图控制器的第一个孩子是否类型为SecondViewController
但是在if语句中,我得到了错误:
Binary operator '==' cannot be applied to operands of type 'Any.Type' and 'T'
Run Code Online (Sandbox Code Playgroud)