0

I am building an iOS application in Swift.

The access to the data store is handled using a Repository which is a protocol.

Is it a good idea to use a struct for the implementation of the Repository or should it be a class?

What my concern is that, if the repository implementation is a struct, then copying a Repository on assignment might lead to several copies each having slightly different sets of data.

vishnus
  • 728
  • 2
  • 7
  • 20
  • 1
    Possible duplicate of [Why Choose Struct Over Class?](http://stackoverflow.com/questions/24232799/why-choose-struct-over-class) – Rashwan L Oct 25 '16 at 10:29
  • Hi @RashwanL - This question is not a duplicate. Kindly read it. I've edited the title to make it clear – vishnus Oct 25 '16 at 10:31
  • 2
    simple rule to follow: Use classes if you want reference types, use structs if you want value types :) – Suhit Patil Oct 25 '16 at 10:38
  • @suhit- I understand that. But in my specific case what should the repository implementation be? – vishnus Oct 25 '16 at 11:24

0 Answers0