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

iOS

Resetting defaultStack in "Core Data"

I've been trying to make the diary app work for multiple users, so I need to clear out the CoreDataStack when users log out.

I've written a method that sets _persistentStoreCoordinator = nil on log out, but since the defaultStack method uses dispatch_once, the app crashes because the persistentStoreCoordinator isn't initialized when a different user logs in.

Is there a way to set the CoreDataStack to nil on log out, so that the dispatch_once method will run again once a new user logs on?

John