<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKAttribute/init(name:type:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKAttribute(im)initWithName:type:"
  },
  "title" : "init(name:type:)"
}
-->

# init(name:type:)

Creates and initializes a new attribute object of a specified type with a name that can be referenced within the shader.

```
init(name: String, type: SKAttributeType)
```

## Parameters

`name`

The name of the attribute.

`type`

The type of the attribute.

## Return Value

A new attribute object.

## Discussion

Attribute names are typically named with a preceding “a” and an underscore. The following code shows how to initialize an attribute named `a_frequency` which is of type [`SKAttributeType.float`](/documentation/SpriteKit/SKAttributeType/float).

```swift
let attribute = SKAttribute(name: "a_frequency", 
                            type: SKAttributeType.float)
```

---

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)