views:

109

answers:

1

HI,

I have a plist that comprises an array of dictionaries that each contain multiple dictionaries of strings. That is I have a:

MusicDataArray-->Mel  ---->filename1
                      ---->filename2
                      ---->filename3
              -->Bass ---->filename1
                      ---->filename2

I need to read this plist into core data where the core data has a 1 to many relationships between MusicData and Bass/Mel. I can read in an array of dictionaries no problem using:

NSString *nodePath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
NSArray *nodeItems = [NSArray arrayWithContentsOfFile:nodePath];

NSManagedObjectContext *nodeCtx = self.managedObjectContext;

for (NSDictionary *dict in nodeItems) {
    NSManagedObject *m = [NSEntityDescription insertNewObjectForEntityForName:plistName inManagedObjectContext:nodeCtx];
    [m setValuesForKeysWithDictionary:dict];
}

However, I am having a problem with the third level in the structure (filenames), in this case the dictionary of filenames that need to be inserted into seperate entities (i.e mel,bass) in multiples.

Can anyone give me some pointers in realtion to solving this problem. should I be using this level of complexity in a plist?

EDITED...

The plist has the following structure:

<plist version="1.0">
<array>
    <dict>
        <key>theID</key>
        <string>0</string>
        <key>mel</key>
        <dict>
            <key>filename1</key>
            <string>melLoop1</string>
            <key>filename2</key>
            <string>melLoop2</string>
            <key>filename3</key>
            <string>melLoop3</string>
        </dict>
        <key>bass</key>
        <dict>
            <key>filename1</key>
            <string>bass1</string>
            <key>filename2</key>
            <string>bass2</string>
            <key>filename3</key>
            <string>bass3</string>
        </dict>
        <key>harm2</key>

where Musicdata as the main entity has a to many relationship with mel, harm1, harm2 etc, where each one has may filenames.

I tried adding an image but I am not able to at this point, not enough reputation points!

A: 

Can you give an example of the structure of the data in the plist files? Can you show your data model?

Marcus S. Zarra
I have edded some edits above to clarify the questions. I tried to add an image of my data model but I am not eligible yet!