• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
What type category should I use for my model in Swift?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: What type category should I use for my model in Swift?
      • From: Quincey Morris <email@hidden>
    • Re: What type category should I use for my model in Swift?
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: PDF image template comes out too small
  • Next by Date: Re: What type category should I use for my model in Swift?
  • Previous by thread: Re: PDF image template comes out too small
  • Next by thread: Re: What type category should I use for my model in Swift?
  • Index(es):
    • Date
    • Thread