Core Data help.

Discussion in 'iOS Programming' started by Ernie11, May 10, 2014.

  1. Ernie11 macrumors member

    Joined:
    Apr 4, 2014
    #1
    Hello everyone. I ran into a situation in which I haven't been before and was hoping for some help. First I will say what I have and then what it is I want at the end.

    I have an entity with various attributes. So after someone saves I have this structure:
    [A]
    -(a)
    -(b)
    -(c)
    -(d)
    new save produces:

    -(a)
    -(b)
    -(c)
    -(d)
    and so on. Well the problem is that one of the attributes is a records keeping one. I have to store more than one variable under one attribute multiple times, like this.
    [A]
    -(a)
    -(b)
    --(a)
    --(b)
    --(c)
    -(c)
    -(d)
    What I found from my research is something about relationship but im not to sure if this will do what I want or how it works. Do I have to make 2 entities? the one I have now and "Records"? How does it know if the records belong to [A] or ? Btw, the information in the entity is user inputted and the records will also be user inputted information. In a little story type, I can produce the filing cabinets and the folders in the filing cabinets, but i need to now produce the multiple files inside the folders. If that makes sense. Thanks.
     
  2. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #2
    Short answer yes relationships....

    Long answer on how to use them is go back to source book you used to learn cocoaTouch there should be a chapter or two on core data work through that first as it should cover relationship and model versioning which you'll need to know about sooner or later so why not now.
     
  3. Ernie11 thread starter macrumors member

    Joined:
    Apr 4, 2014
    #3
    Ok thanks you very much. I was on the right track. Btw, will there be a problem having a relationship between entities when using a singleton model? Thanks again.
     
  4. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #4
    Core data only knows how to move you data from one model to the next if you version the model file and even then it might need help.

    You can keep a single model file but if you change it you'll need to throw out any existing data and start from scratch. Ok if your still early testing and the only one effected is yourself.


    Which is why I say it's something you'll need to learn sooner or later.
     
  5. Ernie11 thread starter macrumors member

    Joined:
    Apr 4, 2014

Share This Page