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

Zenek Barburka
Zenek Barburka
7,009 Points

using Core Data to model a class

If Entity in Core Data has the same name as class in code does it mean that all the properties need to be reflected in Core Data?

I would like to store only some properties of my class as other are either an array or are calculated based on stored properties. As soon as I create an Entity with the same name as class I get a compiler error - Invalid Redeclaration.

Is using an intermediate class a solution? Such class would only have properties corresponding to attributes in coredata, and would be used to initiate the final class.

If you don't want to use MVVM architectural pattern, you can use partial classes. You can give the same name to the class by defining it as a partial class. The properties that you have added to a partial class won't be mapped into your database. This will be used especially for enumeration declarations, associated class properties or calculated data.