<!--
{
  "availability" : [
    "macOS: 10.4.0 - 10.13.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/lockFocusIfCanDraw(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)lockFocusIfCanDrawInContext:"
  },
  "title" : "lockFocusIfCanDraw(in:)"
}
-->

# lockFocusIfCanDraw(in:)

Locks the focus to the view atomically if drawing can occur in the specified graphics context.

```
func lockFocusIfCanDraw(in context: NSGraphicsContext) -> Bool
```

## Parameters

`context`

The graphics context in which drawing might occur. See the discussion for the implications of the type of context.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if successful; otherwise, returns <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

---

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)