Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Chris Olstad
Chris Olstad
1,540 Points

Saving Core Data to a CSV or Text File

I'm hoping someone here can help me with a little problem I've been having with my app.

I created an app that allows teachers to enter data on their students. I'm using Core Data to manage data; there are currently two entities, one that maintains a list of students and a second that maintains a list of tracked data per student (a one-to-many relationship, students to tracked data).

Everything saves and fetches perfectly. My problem is that I would like to give users the ability to save their data to CSV, or just a delimited text file, so they can chart and work with their data in Excel (and the like). Here is where I'm running into problems: when I try to save the data to a file, I'm getting a relationship fault and my app isn't creating my file.

As I understand it, a fault are Objective C's way of referencing data quickly. If that's so, how can I fetch the actual data and not the fault?

I've been banging my head against a wall for a week trying to figure this out. Has anyone else run into this issue?

1 Answer