<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/rulerView(_:shouldAdd:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)rulerView:shouldAddMarker:"
  },
  "title" : "rulerView(_:shouldAdd:)"
}
-->

# rulerView(_:shouldAdd:)

Returns whether a new marker can be added.

```
func rulerView(_ ruler: NSRulerView, shouldAdd marker: NSRulerMarker) -> Bool
```

## Parameters

`ruler`

The ruler view sending the message.

`marker`

The marker to be added.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `aMarker` can be added, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

The receiver checks for permission to make the change by invoking [`shouldChangeText(in:replacementString:)`](/documentation/AppKit/NSTextView/shouldChangeText(in:replacementString:)) and returning the return value of that message. If the change is allowed, the receiver is then sent a [`rulerView(_:didAdd:)`](/documentation/AppKit/NSTextView/rulerView(_:didAdd:)) message.

---

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)