Learn Courses My Dashboard

Code Data Objects

I’m writing a “simple” Address Book app to practice the skills I’ve learned here, and I’ve learned a lot! Thank you.

I would like to write the app so that I can plug in different database drivers. For example, the View that adds first name and last name to the database would not need to know if the database is CoreData, Firebase, or any other driver.

I’m starting with CoreData and would like to encapsulate all database access into one class and am having problems. Where can I read about this subject or find examples. I think I understand Chris’s database tutorials, but I would like to move all CoreData access out of the main view and into a “Person” class.

During my career, I mostly wrote procedural code and don’t have a good handle on the Object Oriented paradigm. Specifically, I’m expert in C language and Visual Basic, but only dabbled in C++ and never wrote in C#.

What you’re looking for is called protocols Which is what it’s called in Swift, other languages call them interfaces.

You make a protocol that can have certain functions, but specifically how you implement them is different in a concrete class

Search around for “generic database access layer swift”