<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSFunction/init(coder:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSFunction(im)initWithCoder:"
  },
  "title" : "init(coder:)"
}
-->

# init(coder:)

```
init?(coder aDecoder: NSCoder)
```

## Discussion\abstract Called by NSCoder to decode MPSKernels
\discussion This standard method doesn’t allow for control over which device the object
targets. By default this will be the Metal system default device. If you want
another device, use the MPSKeyedUnarchiver or other <MPSDeviceProvider>
to decode the function.

---

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)