Add @discardableResult
This commit is contained in:
parent
eda807ff4b
commit
70a2232215
|
@ -21,12 +21,16 @@ open class Navigator {
|
||||||
self.router.append(route: route)
|
self.router.append(route: route)
|
||||||
}
|
}
|
||||||
|
|
||||||
open static func push(url: URL, animated: Bool) {
|
@discardableResult
|
||||||
|
open static func push(url: URL, animated: Bool) -> UIViewController? {
|
||||||
if
|
if
|
||||||
let viewController = self.router.push(url: url),
|
let viewController = self.router.push(url: url),
|
||||||
let navigationController = self.rootViewController as? UINavigationController
|
let navigationController = self.rootViewController as? UINavigationController
|
||||||
{
|
{
|
||||||
navigationController.pushViewController(viewController, animated: animated)
|
navigationController.pushViewController(viewController, animated: animated)
|
||||||
|
return viewController
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,9 +40,13 @@ open class Navigator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open static func present(url: URL, animated: Bool, completion: (() -> Void)? = nil) {
|
@discardableResult
|
||||||
|
open static func present(url: URL, animated: Bool, completion: (() -> Void)? = nil) -> UIViewController? {
|
||||||
if let viewController = self.router.push(url: url) {
|
if let viewController = self.router.push(url: url) {
|
||||||
self.rootViewController?.present(viewController, animated: animated, completion: completion)
|
self.rootViewController?.present(viewController, animated: animated, completion: completion)
|
||||||
|
return viewController
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ open class Router<T> {
|
||||||
self.routes.append(AnyRoute(route))
|
self.routes.append(AnyRoute(route))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
open func push(url: URL) -> T? {
|
open func push(url: URL) -> T? {
|
||||||
let queries = url.queryItems?.reduce(into: [:]) { result, item in
|
let queries = url.queryItems?.reduce(into: [:]) { result, item in
|
||||||
result[item.name] = item.value ?? "true"
|
result[item.name] = item.value ?? "true"
|
||||||
|
|
Loading…
Reference in New Issue