title: How to fetch distinct values in Core Data?
body: <p>So in looking through <a href="http://developer.apple.com/iphone/library/documentation/DataManagement/Conceptual/CoreDataSnippets/Articles/fetchExpressions.html" rel="noreferrer">Core Data Snippets</a>, I found the following code:</p>
  
  <pre><code>...
  [request setEntity:entity]; 
  [request setResultType:NSDictionaryResultType];
  [request setReturnsDistinctValues:YES];
  [request setPropertiesToFetch:[NSArray arrayWithObject:@"&lt;#Attribute name#&gt;"]];
  
  // Execute the fetch
  NSError *error;
  id requestedValue = nil; // WTF? This isn't defined or used anywhere
  NSArray *objects = [managedObjectContext executeFetchRequest:request error:&amp;error];
  if (objects == nil) {
       // handle the error
  }
  </code></pre>
  
  <p>This is great and seems perfect for what I need...but how does one actually use it? I assume since it's returning dictionaries, I need a key to get at the values - but where's the key defined? Is that the "id requestedValue = nil" line? If so, how does "requestedValue" become the key? Xcode gives me a compiler warning about an unused variable at the "requestedValue" declaration. I feel like I'm missing something here.</p>
  
  <p>Thanks in advance for any assistance you can offer.</p>