title: NSMetadataQuery ignoring custom file package type
body: <p>I'm using <code>UIManagedDocument</code>s to manage my files in iCloud. After setting up the <code>NSMetadataQuery</code> like so:</p>
  
  <pre><code>iCloudQuery = [[NSMetadataQuery alloc] init];
  [iCloudQuery setSearchScopes:
      [NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
  [iCloudQuery setPredicate:
      [NSPredicate predicateWithFormat:@"%K like %@", NSMetadataItemFSNameKey, @"DocumentMetadata.plist"]];
  </code></pre>
  
  <p>I'm encountering a curious problem - when my documents are named without a file extension (for example <code>@"NewDocument2"</code>) or a public extension like <code>.txt</code>, the metadata query correctly finds the <code>DocumentMetadata.plist</code> file. However, when using my custom file extension, the query never finds anything... not when the query starts, nor when I add a new document.</p>
  
  <p>It seems to me that the query is probably seeing my document with its custom file extension, is not realising that it is, in fact, a <em>directory</em> (a file package at any rate), and so does not look inside to find the <code>DocumentMetadata.plist</code> file. However, I have declared my custom UTI in the app's <code>info.plist</code>.</p>
  
  <p>Perhaps I have declared my UTI wrongly? I followed Apple's guidelines (in the <a href="http://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/DocumentImplPreflight/DocumentImplPreflight.html#//apple_ref/doc/uid/TP40011149-CH3-SW8">Document-Based App Programming Guide for iOS</a> and <a href="http://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_declare/understand_utis_declare.html#//apple_ref/doc/uid/TP40001319-CH204-SW2">Uniform Type Identifiers Overview</a>) in creating it, but it seems like something is wrong.</p>
  
  <hr>
  
  <p><em>Edit:</em> Under 'Exported UTIs' in the <code>info.plist</code>, my type is set to conform to 'com.apple.package'.</p>
  
  <hr>
  
  <p><em>Edit:</em>
  I'm still struggling with this issue. I'm working around it for now by not using a file extension.</p>
  
  <p>When using the custom file extension, I'm processing the iCloud metadata query results and the <code>DocumentMetadata.plist</code> file is definitely inside the file package, but the metadata query can't see it. When enumerating the query results, the following is printed to the log:</p>
  
  <pre><code>&lt;iCloud Container URL&gt;/Documents/
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/DocumentMetadata.plist
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/StoreContent.nosync/
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/StoreContent.nosync/(A%20Document%20Being%20Saved%20By%20&lt;AppName&gt;%202)/
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/StoreContent.nosync/(A%20Document%20Being%20Saved%20By%20&lt;AppName&gt;)/
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/StoreContent.nosync/.persistentStore_SUPPORT/
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/StoreContent.nosync/.persistentStore_SUPPORT/_EXTERNAL_DATA/
  &lt;iCloud Container URL&gt;/Documents/New%20Document.spdoc/StoreContent.nosync/persistentStore
  </code></pre>
  
  <p><em>(There are also a bunch of files in a "CoreDataLogs" directory, however I didn't show them here for brevity).</em></p>
  
  <p>I can only think that this problem is something to do with incorrectly creating my file package UTI. Has anybody else successfully used custom file packages with iCloud? Is this a bug?</p>