<!--
{
  "availability" : [
    "macOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/webScriptName(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(cm)webScriptNameForSelector:"
  },
  "title" : "webScriptName(for:)"
}
-->

# webScriptName(for:)

Returns the scripting environment name for a selector.

```
class func webScriptName(for selector: Selector!) -> String!
```

## Parameters

`selector`

The selector.

## Return Value

The name used to represent the selector in the scripting environment.

## Discussion

It is your responsibility to ensure that the returned name is unique to the script invoking this method. If this method returns `nil` or you do not implement it, the default name for the selector is constructed as follows:

- A colon (”:”) in the Objective-C selector is replaced by an underscore (”_”).
- An underscore in the Objective-C selector is prefixed with a dollar sign (”$”).
- A dollar sign in the Objective-C selector is prefixed with another dollar sign.

The following table shows examples of how the default name is constructed:

|Objective-C selector            |Default script name for selector  |
|--------------------------------|----------------------------------|
|`setFlag:`                      |`setFlag_`                        |
|`setFlag:forKey:withAttributes:`|`setFlag_forKey_withAttributes_`  |
|`propertiesForExample_Object:`  |`propertiesForExample$_Object_`   |
|`set_$_forKey:withDictionary:`  |`set$_$$_$_forKey_withDictionary_`|

Since the default construction for a method name can be confusing depending on its Objective-C name, you should implement this method and return a more human-readable name.

---

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)