ConnectionManager

@objcMembers public final class ConnectionManager: NSObject

Controller for Connection instances, where connections can be separated into groups (see ConnectionManager.Group).

  • The main group. By default, all connections are tracked in this group, unless specified otherwise.

    Declaration

    Swift

    public let mainGroup: ConnectionManager.Group
  • Validator for accepting/rejecting block-level connection logic.

    Declaration

    Swift

    public let connectionValidator: ConnectionValidator
  • Adds a new ConnectionManager.Group to the manager for a given block.

    Declaration

    Swift

    public func startGroup(forBlock block: Block?) -> ConnectionManager.Group

    Return Value

    The newly created connection group

  • Moves all connections from one group to another group. The first group is automatically deleted after this operation is completed (unless both groups are the same).

    Declaration

    Swift

    public func mergeGroup(_ fromGroup: ConnectionManager.Group, intoGroup: ConnectionManager.Group?)
  • Adds this connection to the manager, listens for changes in its position, and assigns it to a group.

    Declaration

    Swift

    public func trackConnection(
        _ connection: Connection, assignToGroup group: ConnectionManager.Group? = nil)
  • Removes this connection from the manager and stops listening for changes to its position.

    Declaration

    Swift

    public func untrackConnection(_ connection: Connection)
  • Untracks all connections that are not associated with a source block.

    Declaration

    Swift

    public func untrackOrphanedConnections()
  • Iterate over all direct connections on a given group’s ownerBlock and find the one that is closest to a valid connection on another block.

    Declaration

    Swift

    public func findBestConnection(
        forGroup group: ConnectionManager.Group, maxRadius: CGFloat) -> ConnectionPair?

    Return Value

    A connection pair where the pair.moving connection is one on the given block and the pair.target connection is the closest compatible connection. Nil is returned if no suitable connection pair could be found.

  • Finds all compatible connections (including shadow connections) within the given radius, that are not currently being dragged. This function is used for bumping so type checking does not apply.

    Declaration

    Swift

    public func stationaryNeighbors(
        forConnection connection: Connection, maxRadius: CGFloat) -> [Connection]

    Return Value

    A list of all nearby compatible connections.