Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:53:11+00:00 2026-06-13T23:53:11+00:00

I have an iOS application that uses a simple UIDocument model with a single

  • 0

I have an iOS application that uses a simple UIDocument model with a single content field for iCloud storage. I retrieve the list of documents to populate a UITableView using an NSMetadataQuery. I want to have new documents appear at the top of this table, but the default sorting appears to be old -> new.

I know if I had a custom date field in the document I could sort the query with the NSSortDescriptor on that field but my question is is it possible to sort by the intrinsic modification date of the file created through the UIDocument iCloud storage? Or is there another preferred method to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:53:11+00:00Added an answer on June 13, 2026 at 11:53 pm

    Looks like the right way to do this would be to set the sort descriptor of your query when you create it. Something along these lines:

    NSMetadataQuery *query = [[NSMetadataQuery alloc] init];
    [query setSearchScopes:[NSArray arrayWithObject:
                                NSMetadataQueryUbiquitousDocumentsScope]];
    
    NSPredicate *pred = [NSPredicate predicateWithFormat: @"%K ENDSWITH '.bin'", 
                                       NSMetadataItemFSNameKey];
    [query setPredicate:pred];
    
    NSSortDescriptor *sortDescriptor = 
        [[[NSSortDescriptor alloc] initWithKey:NSMetadataItemFSContentChangeDateKey 
                                     ascending:FALSE] autorelease]; //means recent first
    NSArray *sortDescriptors = [NSArray arrayWithObjects:
                                    sortDescriptor,
                                    nil];        
    [query setSortDescriptors:sortDescriptors];
    
    [[NSNotificationCenter defaultCenter] 
         addObserver:self 
         selector:@selector(queryDidFinishGathering:) 
         name:NSMetadataQueryDidFinishGatheringNotification 
         object:query];
    
    [query startQuery];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an iOS application that uses GPS for Location Services. A user would
I have an application that is developed for ios lower than ios 5.. it
In my iOS application I have made a form that should submit data into
I have an AIR application that I'm compiling to mobile. There is an iOS
I'm developing an iOS 4 application. I have a main view that contains another
for an iOS 5.0 application using ARC, i have an NSArray of objects that
i have an iOS application witch uses the current location of the user. I
I have an application that uses UIDatePicker & I am facing problem as described
I have an application that uses a UIScrollView to page between a number of
So I have been working on this phone gap application that uses jquery-mobile. Recently,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.