eelco
eelco

Reputation: 218

persistent store entries remain but data is empty when rebuilding

I'm working on an App that uses a persistent store to save and retreive data. I have it all working, but there is some curious behavior that makes me doubt very much if what I'm doing is correct.

When I build my App, some values are loaded into the persistent store and can be accessed. This remains true when I close the App in the interface builder and then reload it.

The loaded data, when logged, looks shortly like:

entity: Appointment; data: { day = monday; hours = 8; project = project1; task = task1; }

Now, when rebuilding the App, the entries in the store are still present, however, the data that should be in those entries appears to be destroyed.

The loaded data now looks like:

entity: Appointment; data: fault

I would assume that either the store is rebuilt entirely and thus no entries would remain, or it would stay intact as it was before rebuilding.

An appointment is of NSManagedObject class defined in my xcdatamodel, and has four string attributes (day, hours, project and task).

Upvotes: 0

Views: 149

Answers (2)

Lorenzo B
Lorenzo B

Reputation: 33428

Without the code it's difficult to see what is going on. Did you receive an error?

data:fault does not mean you do something wrong. Each time you do a request, Core Data does not retrieve the whole object but a skeleton of it. Data within the object are not populated immediately but only when you fire a fault (e.g. accessing a property of that entity).

So, if you log that object in this manner:

NSLog(@"%@", managedObject);

this could be the motivation of that.

For further info about faulting I suggest you to read Faulting.

Hope it helps.

Upvotes: 1

Kjuly
Kjuly

Reputation: 35141

  1. Run your simulator, then in top menu bar, choose iOS Simulator -> Reset Content & Settings.... It'll reset all data for your App, including CoreData.

  2. Or your can go to ~/Library/Application\ Support/iPhone\ Simulator/5.0/Applications, delete the App bundle.

  3. Or just delete the xxx.sqlite file in ~/Library/Application\ Support/iPhone\ Simulator/5.0/Applications/E88E378D-14A9-4900-A613-BF9082D4B2C1(YourAppBundle)/Documents/.

Then rebuild your project and run it, clean data now. ;)

Upvotes: 0

Related Questions