---
title: "objectID(for:withReferenceObject:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsatomicstore/objectid(for:withreferenceobject:)"
---

# objectID(for:withReferenceObject:)

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

## Declaration

```swift
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

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

## Discussion

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.

## See Also

### Loading a Store

- [load()](coredata/nsatomicstore/load().md)
- [addCacheNodes(_:)](coredata/nsatomicstore/addcachenodes(_:).md)
