title: Understanding CoreData in iOS Swift
body: <p>I am building an app at the moment and am trying to get my head around the concept of CoreData. I have created a data model for the app based on the advice from this link...</p>
  
  <p><a href="https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson6.html" rel="nofollow">Apple "Define Your Data Model" Link</a></p>
  
  <p>Currently, I am just using some test data locally for development purposes. Here is the sample object class I have created...</p>
  
  <pre><code>import UIKit
  
  func ==(lhs: Recipe, rhs: Recipe) -&gt; Bool {
      return lhs.hashValue == rhs.hashValue
  }
  
  class Recipe: Hashable {
  
  dynamic var ID : Int = 0
  dynamic var recipeName: String = ""
  dynamic var recipeDescription:String = ""
  dynamic var servings: Int = 0
  dynamic var cookTime: Double = 0.0
  dynamic var image: String? = ""
  
  var hashValue : Int {
      get {
          return "\(self.ID)".hashValue
      }
  }
  init?(id: Int, name: String, description: String, servings: Int, cooktime: Double, image: String) {
      self.ID = id
      self.recipeName = name
      self.recipeDescription = description
      self.servings = servings
      self.cookTime = cooktime
      self.image = image
  
      if id &lt; 0 || name.isEmpty || description.isEmpty || cookTime &lt; 0 || servings &lt; 0 {
          return nil
      }
  }
  }
  </code></pre>
  
  <p>I have then initialized some of those objects locally to be used during development and they work fine.</p>
  
  <p>My question is...</p>
  
  <p>When it comes time to use storage like CoreData or RealmSwift, will this type of data model be irrelevant? Will I make an entirely new data model (in Realm for example)? or will this type of data model play nicely with one of the DB models?</p>
  
  <p>Most importantly, will building my data model like this now and incorporating CoreData or RealmSwift after be the cause of a lot of code refactoring? If this is the case then would it be advisable to drop the frontend development and build the entire data model before moving forward?</p>