<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKObstacleGraph/isConnectionLocked(from:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKObstacleGraph(im)isConnectionLockedFromNode:toNode:"
  },
  "title" : "isConnectionLocked(from:to:)"
}
-->

# isConnectionLocked(from:to:)

Returns a Boolean value indicating whether the specified nodes are protected from disconnection due to the addition of obstacles.

```
func isConnectionLocked(from startNode: NodeType, to endNode: NodeType) -> Bool
```

## Parameters

`startNode`

A node in the graph.

`endNode`

Another node in the graph to which the node `startNode` is directly connected.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the connection between the specified nodes has been locked with the [`lockConnection(from:to:)`](/documentation/GameplayKit/GKObstacleGraph/lockConnection(from:to:)) method; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

By default, adding obstacles with the [`addObstacles(_:)`](/documentation/GameplayKit/GKObstacleGraph/addObstacles(_:)) method disconnects pairs of nodes if the direct path between them intersects an obstacle. This behavior ensures that using the findPathBetweenNodes:toNode: method does not result in a path through the graph that crosses obstacles. With certain nodes, this behavior might not be desirable—use the [`lockConnection(from:to:)`](/documentation/GameplayKit/GKObstacleGraph/lockConnection(from:to:)) method to protect a connection between nodes from being automatically destroyed and the [`unlockConnection(from:to:)`](/documentation/GameplayKit/GKObstacleGraph/unlockConnection(from:to:)) method to remove such protection.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)