title: how to insert a Dictionary into an array
body: <p>I am quite new to iOS and Objective-c. 
  I am trying to auto generate a <code>pList</code> in my app that looks like this.</p>
  
  <p><img src="https://i.stack.imgur.com/JQsQD.png" alt="enter image description here"></p>
  
  <p>I've so far been able to create the file making it a normal <code>Value =&gt; Key</code> file if i replace my for loop by</p>
  
  <pre><code>for (NSString* exercisePictureName in bigPictureData) {
  
          [data setObject:exercisePictureName forKey:exercisePictureName];
  
      }
  </code></pre>
  
  <p>but my problem is that I have no idea how to structure the logic at the end of my loop to create a file structure like shown in the picture. As it has to be exact.</p>
  
  <p>Could anyone point me in the right direction on how to structure my loop so that it creates the file with the right format???? </p>
  
  <pre><code>- (void) createImageListFromSource {
  
  
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *path = [documentsDirectory stringByAppendingPathComponent:@"exercisePictures.plist"];
      NSFileManager *fileManager = [NSFileManager defaultManager];
  
      if (![fileManager fileExistsAtPath: path])
      {
          path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"exercisePictures.plist"] ];
      }
  
  
      //To insert the data into the plist
      NSArray* bicepPictureData = [self getAllimagesThatStartWith:@"bicep-"];
      NSArray* tricepPictureData = [self getAllimagesThatStartWith:@"tricep-"];
      NSArray* absPictureData = [self getAllimagesThatStartWith:@"abs-"];
      NSArray* chestPictureData = [self getAllimagesThatStartWith:@"chest-"];
      NSArray* backPictureData = [self getAllimagesThatStartWith:@"back-"];
  
      NSArray* bigPictureData = [bicepPictureData arrayByAddingObjectsFromArray:tricepPictureData];
      bigPictureData = [bigPictureData arrayByAddingObjectsFromArray:absPictureData];
      bigPictureData = [bigPictureData arrayByAddingObjectsFromArray:chestPictureData];
      bigPictureData = [bigPictureData arrayByAddingObjectsFromArray:backPictureData];
  
      NSArray* finalData = [[NSArray alloc] init];
      for (NSString* exercisePictureName in bigPictureData) {
  
          NSDictionary* data = [[NSDictionary alloc] initWithObjectsAndKeys:exercisePictureName,@"text",exercisePictureName,@"image", nil];
          [finalData arrayByAddingObject:data];
          NSLog(@"%@",data);
      }
      NSLog(@"%@",finalData);
      [finalData writeToFile: path atomically:YES];
  
  }
  </code></pre>