Search code examples
ioscore-dataswiftxcode6

Adding core data to existing tabbed application (ios swift, Xcode6)


I've created a mess around To Do list app in Tabbed Application, Xcode 6 beta. Currently giving this a go in swift.

How do I go about getting the core data added into the app delegate file? When I go to create a new tabbed application there is no option to get it added. I notice you can turn core data on in other project templates but not this one?


Solution

  • The easiest way to do so is just creating a new application with Core Data enabled, copy and paste the code from AppDelegate.swift and create a new Core Data Model (Cmd + N > iOS - Core Data > Data Model). The only thing you have to do is replace the database name from your demo project with the name you chose for the Core Data Model you created. To do so, just search for your old project name in the code you pasted and replace it with the name of your new Core Data Model.

    I also tested what you said and the missing Core Data checkbox for tabbed applications should be an Xcode 6 bug but it does not really matter which template you choose for the application. The Core Data code is the same across all the templates, the only difference between these options is the interface that is generated by Xcode.