Sqlite and Core Data

Discussion in 'iOS Programming' started by kimbebot, Jun 26, 2012.

  1. kimbebot macrumors newbie

    Joined:
    Jun 26, 2012
    #1
    Hi, I am new to iOS app development. I have my sqlite database and I want to fetch records from it using Core Data. How is it possible? Can you provide me a simple tutorial? Thanks for your help! :)
     
  2. vonbaron macrumors newbie

    Joined:
    Nov 8, 2011
    #2

    Short answer is that you cannot use core data to access sqlite. Core data is designed to work with data, not to work with a database.

    That being said, you can use sqlite to upload data into a Managed Object and then use core data to access the data from there. You can do this by

    1) Modeling your data in Xcode
    2) Read each record from your database. For each record create a new Managed Object and using KVC set the values of your attributes.
     
  3. puge09 macrumors newbie

    Joined:
    Apr 10, 2011
    #3
    Thanks for making it clear for me, do you have a good tutorial for that?
     
  4. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
  5. kimbebot thread starter macrumors newbie

    Joined:
    Jun 26, 2012
    #5
    Thanks jnoxx for your reply, I successfully followed this tutorial and I was able to create my own example. Right now I want to create a sqlite database using core data, but this time I want to create multiple tables with relationships. Do you have a good tutorial for this? Thanks! :)
     
  6. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #6
    Edit your CoreDataModel (instead of using an existing SQLite), with inverse relations etc, this will create the database for you :)
     

Share This Page