<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSObjectSetPrivate(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:@F@JSObjectSetPrivate"
  },
  "title" : "JSObjectSetPrivate(_:_:)"
}
-->

# JSObjectSetPrivate(_:_:)

Sets a pointer to private data on an object.

```
func JSObjectSetPrivate(_ object: JSObjectRef!, _ data: UnsafeMutableRawPointer!) -> Bool
```

## Parameters

`object`

The [`JSObjectRef`](/documentation/JavaScriptCore/JSObjectRef) with the private data you want to set.

`data`

A pointer to set as the object’s private data.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `object` can store private data; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

The default object class doesn’t allocate storage for private data. Only objects that have a non-`NULL` [`JSClassRef`](/documentation/JavaScriptCore/JSClassRef) can store private data.

---

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)