---
title: "setURL(_:for:)"
framework: coredata
role: symbol
role_heading: Instance Method
path: "coredata/nspersistentstorecoordinator/seturl(_:for:)"
---

# setURL(_:for:)

Changes the location of the specified persistent store.

## Declaration

```swift
func setURL(_ url: URL, for store: NSPersistentStore) -> Bool
```

## Parameters

- `url`: The new location for store.
- `store`: A persistent store associated with the receiver.

## Return Value

Return Value true if the store was relocated, otherwise false.

## Discussion

Discussion For atomic stores, this method alters the location to which the next save operation will write the file; for non-atomic stores, invoking this method will relinquish the existing connection and create a new one at the specified URL. (For non-atomic stores, a store must already exist at the destination URL; a new store will not be created.)

## See Also

### Managing a store’s location

- [persistentStore(for:)](coredata/nspersistentstorecoordinator/persistentstore(for:).md)
- [url(for:)](coredata/nspersistentstorecoordinator/url(for:).md)
