<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSValue/init(_:withObjCType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSValue(cm)value:withObjCType:"
  },
  "title" : "init(_:withObjCType:)"
}
-->

# init(_:withObjCType:)

Creates a value object containing the specified value, interpreted with the specified Objective-C type.

```
init(_ value: UnsafeRawPointer, withObjCType type: UnsafePointer<CChar>)
```

## Parameters

`value`

A pointer to data to be stored in the new value object.

`type`

The Objective-C type of `value`, as provided by the `@encode()` compiler directive. Do not hard-code this parameter as a C string.

## Return Value

A new value object that contains `value`, which is interpreted as being of the Objective-C type `type`.

## Discussion

This method has the same effect as [`valueWithBytes:objCType:`](/documentation/Foundation/NSValue/valueWithBytes:objCType:) and may be deprecated in a future release. You should use [`valueWithBytes:objCType:`](/documentation/Foundation/NSValue/valueWithBytes:objCType:) instead.

## See Also

[`+  valueWithBytes:objCType:`](/documentation/Foundation/NSValue/valueWithBytes:objCType:)

Creates a value object containing the specified value, interpreted with the specified Objective-C type.



---

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)