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 Build a Diary App Using Core Data Understanding Core Data Typical Core Data Stack

Did you forget a line such as: static dispatch_once_t onceToken; in your defaultStack implementation?

When I attempt to implement the defaultStack method in my THCoreDataStack.m file as demonstrated:

  • (instancetype)defaultStack { static CBLCoreDataStack *defaultStack; dispatch_once(&onceToken, ^{ defaultStack = [[self alloc] init]; }); }

Xcode warns me "use of undeclared identifier onceToken". Should I instead declare the onceToken with a line such as:

static dispatch_once_t onceToken;

In the method implementation?

Thanks for the great tutorials btw!

Correction: there's an inconsistency with my class prefixes. I am using CBL for all of them and forgot to change it to TH when I copied and pasted my code to make it consistent with Tree House's prefixes.