Using structs instead of classes for model "objects" in Swift?

52 views
Skip to first unread message

Jason Job

unread,
Nov 12, 2015, 7:57:17 PM11/12/15
to YapDatabase
Seems everywhere you look these days people are talking about using value types and protocol oriented programming in Swift. I'm interested in using structs instead of classes for my model "objects". (I know they aren't technically objects if they are structs but model structs sounds weird)

While there are several strategies one could use to serialize structs in Swift, I am scratching my head trying to figure out if I could actually use structs like this with YapDatabase because the YapDatabaseSerializer takes an object as its argument. 

Has anyone tried to use structs instead of classes with YapDatabase? Would it even be possible in the current implementation of Yap?  If not, does anyone have ideas about how we could make Yap play nice with structs as our model "objects"?

Nikita Ivanchikov

unread,
Nov 13, 2015, 2:55:24 AM11/13/15
to YapDatabase
Hi Jason!

I've also tried using structs w/ YapDatabase in a side project, but with no success. However one thing I came across recently is "YapDatabaseExtensions" repo by Dan Thorpe - it's aimed to add compatibility for using structs, enums, etc. Unfortunately I hadn't have time to try it out yet, but it looks promising.

Here're the links you may be interested in:

Regards,
Nikita
Reply all
Reply to author
Forward
0 new messages