<!--
{
  "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/NSManagedObjectContext/obtainPermanentIDs(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSManagedObjectContext(im)obtainPermanentIDsForObjects:error:"
  },
  "title" : "obtainPermanentIDs(for:)"
}
-->

# obtainPermanentIDs(for:)

Converts to permanent IDs the object IDs of the objects in a given array.

```
func obtainPermanentIDs(for objects: [NSManagedObject]) throws
```

## Parameters

`objects`

An array of managed objects.

## Discussion

This method converts the object ID of each managed object in `objects` to a permanent ID. Although the object will have a permanent ID, it will still respond positively to [`isInserted`](/documentation/CoreData/NSManagedObject/isInserted) until it is saved. Any object that already has a permanent ID is ignored.

Any object not already assigned to a store is assigned based on the same rules Core Data uses for assignment during a save operation (first writable store supporting the entity, and appropriate for the instance and its related items).

### Special Considerations

This method results in a transaction with the underlying store which changes the file’s modification date.

In macOS, this results an additional consideration if you invoke this method on the managed object context associated with an instance of <doc://com.apple.documentation/documentation/AppKit/NSPersistentDocument>. Instances of `NSDocument` need to know that they are in sync with the underlying content. To avoid problems, after invoking this method you must therefore update the document’s modification date (using <doc://com.apple.documentation/documentation/AppKit/NSDocument/fileModificationDate>).

---

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)