Note that there are some explanatory texts on larger screens.

plurals
  1. POI need to combine two NSArray/NSDictionaries together
    primarykey
    data
    text
    <p>I have two <code>plist</code> files that I'm using as datasources to create <code>NSArray</code> and <code>NSDictionaries</code> in my app.</p> <p>I want the output of the CSV file to look like:</p> <pre><code>exerciseName, muscleGroup, description Barbell Curl, Biceps, This is a bicep exercise </code></pre> <p>The problem is, I need to first combine two NSDictionaries I have. One has exerciseName and muscleName, while the other has exerciseDescription. But I need to have one array of dictionaries for each exercise obejct that has all 3 keys.</p> <p>I'm using the following code to build the main <code>NSMutableArray</code></p> <pre><code>if (muscleArray == nil) { NSString *path = [[NSBundle mainBundle]pathForResource:@"data" ofType:@"plist"]; NSMutableArray *rootLevel = [[NSMutableArray alloc]initWithContentsOfFile:path]; self.muscleArray = rootLevel; } NSMutableArray *arrayForSearching = [NSMutableArray array]; for (NSDictionary *muscleDict in self.muscleArray) for (NSDictionary *excerciseDict in [muscleDict objectForKey:@"exercises"]) [arrayForSearching addObject:[NSDictionary dictionaryWithObjectsAndKeys: [excerciseDict objectForKey:@"exerciseName"], @"exerciseName", [muscleDict objectForKey:@"muscleName"], @"muscleName", nil]]; self.exerciseArray = arrayForSearching; </code></pre> <p>I'm using the following code to build the NSDictionary which has the exerciseDescription key</p> <pre><code> NSString *exerciseNameString =self.exerciseName; NSString *path = [[NSBundle mainBundle] pathForResource:@"ExerciseDescriptions" ofType:@"plist"]; NSDictionary *exerciseDescription = [NSDictionary dictionaryWithContentsOfFile:path]; NSString *description = [exerciseDescription objectForKey:exerciseNameString]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload