<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 4.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSCoder/nsDirectionalEdgeInsets(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@F@NSDirectionalEdgeInsetsFromString"
  },
  "title" : "nsDirectionalEdgeInsets(for:)"
}
-->

# nsDirectionalEdgeInsets(for:)

Returns a directional edge insets structure based on data in the specified string.

```
class func nsDirectionalEdgeInsets(for string: String) -> NSDirectionalEdgeInsets
```

## Parameters

`string`

A string whose contents are of the form “{top, leading, bottom, trailing}”, where top, leading, bottom, trailing are the floating-point component values of the <doc://com.apple.documentation/documentation/AppKit/NSDirectionalEdgeInsets> structure. An example of a valid string is “`{3.0,8.0,3.0,5.0}`”. The string is not localized, so items are always separated with a comma.

## Return Value

A directional edge insets data structure. If the string is not well-formed, the function returns <doc://com.apple.documentation/documentation/AppKit/NSDirectionalEdgeInsetsZero>.

---

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)