<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAppleScript/richTextSource",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAppleScript(py)richTextSource"
  },
  "title" : "richTextSource"
}
-->

# richTextSource

Returns the syntax-highlighted source code of the receiver if the receiver has been compiled and its source code is available.

```
var richTextSource: NSAttributedString? { get }
```

## Discussion

Returns `nil` otherwise. It is possible for an instance of `NSAppleScript` that has been instantiated with [`init(contentsOf:error:)`](/documentation/Foundation/NSAppleScript/init(contentsOf:error:)) to be a script for which the source code is not available, but is nonetheless executable.

---

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)