---
title: "newObjectID(for:referenceObject:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nsincrementalstore/newobjectid(for:referenceobject:)"
---

# newObjectID(for:referenceObject:)

Returns a new object ID that uses given data as the key.

## Declaration

```swift
func newObjectID(for entity: NSEntityDescription, referenceObject data: Any) -> NSManagedObjectID
```

## Parameters

- `entity`: The entity for the new object ID.
- `data`: An object of type doc://com.apple.documentation/documentation/Foundation/NSString or doc://com.apple.documentation/documentation/Foundation/NSNumber to use as the key.

## Return Value

Return Value A new object ID for an instance of the entity specified by entity and that uses data as the key.

## Discussion

Discussion You should not override this method.

## See Also

### Manipulating Managed Objects

- [execute(_:with:)](coredata/nsincrementalstore/execute(_:with:).md)
- [newValuesForObject(with:with:)](coredata/nsincrementalstore/newvaluesforobject(with:with:).md)
- [newValue(forRelationship:forObjectWith:with:)](coredata/nsincrementalstore/newvalue(forrelationship:forobjectwith:with:).md)
- [obtainPermanentIDs(for:)](coredata/nsincrementalstore/obtainpermanentids(for:).md)
- [referenceObject(for:)](coredata/nsincrementalstore/referenceobject(for:).md)
