> On Jun 2, 2016, at 8:55 AM, Daryle Walker <dary...@mac.com> wrote:
> 
> [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.


In practical terms, a model typically both has value and reference types. If 
you take a game example, the data that describes the capabilities of a unit is 
value data, but the unit itself has identity and is thus a reference type. Also 
“Dumb” vs “Smart” data doesn’t really translate well to value vs reference – 
you can have “smart” structs and “dumb” classes (a Box class is a typical 
example of a “dumb" class – its entire purpose is to grant identity to a value 
type) – its really a matter of if you need identity or not.

I would highly recommend you experiment and do what feels for your case.
--
David Duncan


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to