Port array of strings to array of dictionaries each containing a string
<p>I'm trying to port the strings in an array into an array of dictionaries where each dictionary contains one of the strings and a boolean. Hopefully this makes sense, but I'll try and make a diagram:</p>

<p>At the moment I have:</p>

<pre><code>&lt;array&gt;
-&lt;string1&gt;
-&lt;string2&gt;
...
&lt;/array&gt;
</code></pre>

<p>But I want:</p>

<pre><code>&lt;array&gt;
-&lt;dictionary1&gt;
--&lt;string1&gt;
--&lt;bool&gt;
-&lt;/dictionary1&gt;
-&lt;dictionary2&gt;
--&lt;string2&gt;
--&lt;bool&gt;
-&lt;/dictionary2&gt;
...
&lt;/array&gt;
</code></pre>

<p>I've tried creating a loop to cycle through the array of strings, but it doesn't seem to work.</p>

<p>The ultimate goal is to save this new array of dictionaries to the NSUserDefaults (which I'm also fairly unfamiliar with). This is what I have so far, and any help would be much appreciated!</p>

<pre><code>// Get the current array from the user defaults.
NSArray *tempArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"myArrayKey"];
self.myArray = [tempArray mutableCopy];

// Loop to cycle through the array of strings
for(int i = 0; i &lt; [aList count]; i++)
{
    // Boolean to go in the dictionary with the string.
    checked = NO;

    // Create a dictionary, and set it with two objects and two keys. 
   //First object is the string in the array we are cycling through, the second object is the boolean.
    NSDictionary *tempDict = [[NSDictionary alloc] initWithObjectsAndKeys:[aList objectAtIndex:i], @"Title", checked, @"checked", nil];

    // Add this dictionary to the new array of dictionaries.
    [self.myArray addObject:tempDict];

    // This NSLog gives me 0 - but gives me  0 seven times (the number of items in the array I am cycling through) so it is definitely cycling through the array.
    NSLog(@"My Array Count: %i", [myArray count]);

    // Release the tempDict.
    [tempDict release];

}

// Write this new array of dictionaries back to NSUseDefaults.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:myArray forKey:@"myArrayKey"];
[defaults synchronize];
</code></pre>
