Questions tagged [nspersistentstore]

This class is the abstract base class for all Core Data persistent stores. Core Data provides four store types—SQLite, Binary, XML, and In-Memory (the XML store is not available on iOS); these are described in Persistent Store Features. Core Data also provides subclasses of NSPersistentStore that you can use to define your own store types: NSAtomicStore and NSIncrementalStore.Available in iOS 3.0, OS X v10.5 and later.

This class is the abstract base class for all Core Data persistent stores.

Core Data provides four store types—SQLite, Binary, XML, and In-Memory (the XML store is not available on iOS); these are described in Persistent Store Features. Core Data also provides subclasses of NSPersistentStore that you can use to define your own store types: NSAtomicStore and NSIncrementalStore. The Binary and XML stores are examples of atomic stores that inherit functionality from NSAtomicStore.

Subclassing Notes You should not subclass NSPersistentStore directly. Core Data only supports subclassing of NSAtomicStore and NSIncrementalStore.

The designated initializer is initWithPersistentStoreCoordinator:configurationName:URL:options:. When you implement the initializer, you must ensure you load metadata during initialization and set it using metadata.

You must override these methods:

123 questions
23
votes
4 answers

How to debug/handle intermittent "authorization denied" and "disk i/o" errors when adding SQL store to an NSPersistentStoreCoordinator?

I have an app in the app store and am using a logging service to get crash logs and associated log data. I am seeing an intermittent crash (low # of users affected and low # of crashes per user) but it is baffling me. What happens in these crashes…
XJones
  • 21,959
  • 10
  • 67
  • 82
8
votes
1 answer

Core Data Error After Recreating Persistant Store

In my application, I have the ability to clear all data from the database. Once this operation completes, a bundled JSON is then parsed and then saved to the database (in order to return the database to the default state). The operation to parse and…
7
votes
2 answers

core data NSPersistentStore issue

I am developing an application that is rolled out in stages. For each sprint, there are database changes so core data migration has been implemented. So far we have had 3 stage releases. Whenever successive up gradation is done , the application…
Mary
  • 335
  • 4
  • 14
6
votes
1 answer

Should I delete underlying persistent store files after calling destroyPersistentStore on a NSPersistentStoreCoordinator?

I'm migrating my iOS app to use NSPersistentContainer. This class by default locates its persistent store files in the Library/Application Support directory; previously my store files were stored in the Documents directory. I've added a little bit…
Andrew Bennet
  • 2,600
  • 1
  • 21
  • 55
6
votes
0 answers

iOS Core Data NSPersistentStoreCoordinator never opened database

I've got some weird problems with Core Data in my iOS which I cannot seem to reproduce, it just happens from time to time with some users that report it. The error I get from my iOS crash reports: CoreData: -[NSPersistentStoreCoordinator…
Pega88
  • 564
  • 1
  • 6
  • 16
5
votes
1 answer

Application is crashing when creating a options Dictionary used by addPersistentStoreWithType method

I am using encrypted-core-data to encrypts all data that is persisted , previously simple CoreData was using. persistentStoreCoordinator creation code are as follows . - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if…
5
votes
1 answer

NSIncrementalStore - Using local and remote data

I've read a few articles about NSIncrementalStore and I'm still confused about the whole concept. In this post we can read that: Essentially you can now create a custom subclass of NSPersistentStore, so that instead of your NSFetchRequest hitting…
wczekalski
  • 720
  • 4
  • 21
5
votes
2 answers

Optimistic locking support in NSIncrementalStore subclass

I am implementing a custom NSIncrementalStore subclass which uses a relational database for persistent storage. One of the things that I still struggle with is the support for optimistic locking. (feel free to skip this lengthy description right…
5
votes
1 answer

iOS UIManagedDocument : can't open pre loaded persistent store

I'm trying to pre load a persistent store in an app based on UIManagedDocument to deal with core data. Persistent store I try to use in app B, is "generated" and populated thanks to app A. In both app A and B I use the UIManagedDocument handler from…
macbeb
  • 227
  • 2
  • 11
4
votes
0 answers

IOS 10+ Persistence Store Container set parent context to main context

Following a perfect core data stack, we follow this hierarchy. For IOS 10+, Apple introduced NSPersistentContainer. In which Apple described the way for getting background context by let backgroundcontext =…
4
votes
2 answers

Is NSInMemoryStoreType Incompatible with NSBatchDeleteRequest?

I am currently unit testing a layer that interacts with Core Data. It saves, deletes, and updates an Item object. However, my test that attempts to save a couple of Items and then perform a batch deletion keeps failing. This is Item: extension Item…
Nick Kohrn
  • 5,779
  • 3
  • 29
  • 49
4
votes
1 answer

Removing a loaded persistentStore in persistentContainer

I have loaded a specific URL file in persistentContainer using the following: // MARK: Core Data Stack lazy var persistentContainer: NSPersistentContainer = { os_log("In persistent Container", log: OSLog.default, type: .debug) // set URL to…
HeyRef
  • 61
  • 4
4
votes
1 answer

Changing NSPersistentStoreFileProtectionKey for persistent store manager on existing sqlite

When calling addPersistentStoreWithType while the app is in background, my sqlite file sometimes used to be unavailable and i received this error: [Model createPersistentStoreCoordinatorWithStoreURL:] line 387 $ sqlite encryption state…
MarkHim
  • 5,686
  • 5
  • 32
  • 64
4
votes
0 answers

Effect of affectedStores on fetching unsaved NSManagedObjects?

Here is a brief sequence that involves a Core Data stack with an (initially empty) NSManagedObjectContext and a NSPersistentStoreCoordinator with two NSPersistentStores: Player *player = [NSEntityDescription insertNewObjectForEntityForName:…
Drux
  • 11,992
  • 13
  • 66
  • 116
4
votes
1 answer

Migrating existing Core Data to iCloud

I have a simple application which is a UITableView that gets populated by the user filling in some UITextFields in a different view. This information gets saved to CoreData and the UITableView gets updated using NSFetchedResultsController. I'm now…
amitsbajaj
  • 1,304
  • 1
  • 24
  • 59
1
2 3
8 9