URLRouter

public class URLRouter

URLRouter is a way to manage URL routes and invoke them from a URL.

  • The key to get the url from parameters of block handler.

    Declaration

    Swift

    public static let URLRouterURL = RouteParameters.URLRouteURL
  • The type of block handler to be registered.

    Declaration

    Swift

    public typealias URLRouterHandler = ([String: Any]) -> ()
  • Singleton instance of URLRouter.

    Declaration

    Swift

    public static let sharedInstance = URLRouter()
  • Registers a url for calling handler blocks.

    Declaration

    Swift

    public func register(url url: NSURL, handler: URLRouterHandler)

    Parameters

    url

    The url to be registered.

    handler

    The handler to be registered, and will be called while routed.

  • Routes a URL, calling handler blocks (for patterns that match URL) until one returns YES.

    Declaration

    Swift

    public func route(url url: NSURL) -> Bool

    Parameters

    url

    The url for search.

    Return Value

    True if handler block is found and called, false if handler block is not found.

  • Registers a url for calling handler blocks.

    Declaration

    Swift

    public func register<C: UIViewController where C: IntentReceivable>(url url: NSURL, clazz: C.Type)

    Parameters

    url

    The url to be registered.

    clazz

    The UIViewController’s class to be registered, and this view controller will be started while routed.