<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSAtomicStore/objectID(for:withReferenceObject:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAtomicStore(im)objectIDForEntity:referenceObject:"
  },
  "title" : "objectID(for:withReferenceObject:)"
}
-->

# objectID(for:withReferenceObject:)

Returns a managed object ID from the reference data for a specified entity.

```
func objectID(for entity: NSEntityDescription, withReferenceObject data: Any) -> NSManagedObjectID
```

## Parameters

`entity`

An entity description object.

`data`

Reference data for which the managed object ID is required.

## Return Value

The managed object ID from the reference data for a specified entity

## Discussion

You use this method to create managed object IDs which are then used to create cache nodes for information being loaded into the store.

### Special Considerations

You should not override this method.

---

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)