What type category should I use for my model in Swift?
What type category should I use for my model in Swift?
- Subject: What type category should I use for my model in Swift?
- From: Daryle Walker <email@hidden>
- Date: Thu, 02 Jun 2016 11:55:01 -0400
[Warning: rambling]
In Objective-C, you pretty much have to use a class for you model (in your MVC Cocoa app). But in Swift, you have the option to use a struct/enum or a non-NSObject class too.
My model in mind is dumb data, so a struct seems appropriate. But your various Cocoa subclass would need to reference the model, and using a struct means it’s by value instead of reference, so coordinating changes would get harder.
I’m guessing that I could use something like view-models, and only those VMs access the model, and always through referencing the containing object (like a NSDocument subclass). But a reference type, even a non-NSObject one, still seems easier. And I may want to use KVO or Core Data, which require NSObject subclasses.
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden