0

The data in my sqlite table is not being displayed correctly, instead the default value I set in the core-data model is showing.

I added a new field in my sqlite table and updated my core data model. The attribute has the same name and data type as the field I just added in the sqlite file.

When I added the new core-data attribute I made sure to go add new data model version and then set that version.

I also made sure to reset the simulator and cleaned all targets in xcode.

I'm not getting any errors, it's just that I can't get the data to match up.

thanks for any help.

1 Answer 1

2

You may not mess with Core Data's sqlite database directly. Quoth the documentation:

Important: Although Core Data supports SQLite as one of its persistent store types, Core Data cannot manage any arbitrary SQLite database. In order to use a SQLite database, Core Data must create and manage the database itself.

The correct way to do things is to update the Core Data model, follow the Core Data Model Versioning and Data Migration Programming Guide, and let Core Data handle updating the SQLite database itself.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your response. What if I need to add data to the sqlite table?
Create an NSManagedObject and save it. Anomie is right - attempting to manipulate the sqllite store directly will bring you naught but misery.
Forget that Core Data is using an SQLite database. Ask instead "What if I need to add data to Core Data?", and then research that question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.