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

  • SEARCH
  • Home
  • 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 8969089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:32:39+00:00 2026-06-15T17:32:39+00:00

This requirement is very specific to read directory contents along with date modified for

  • 0

This requirement is very specific to read directory contents along with date modified for all sub files and folders. In windows we have some API’s but I didn’t find similar function in Mac OS development. I searched for this where I found that NSFileManager can be used for this.I found one place where I can get the path contents under Documents directory.

Here is the piece of code code which I have.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];

NSFileManager *manager = [[NSFileManager alloc] init];
NSDirectoryEnumerator *fileEnumerator = [manager enumeratorAtPath:documentsPath];

for (NSString *filename in fileEnumerator) {
    // Do something with file
    NSLog(@"file name : %@",filename );
}

But my requirement is to find the contents under any path on machine with the date modified for all sub files and a folders in it.Please guide me on it.

Thanks,
Tausif.

  • 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-15T17:32:40+00:00Added an answer on June 15, 2026 at 5:32 pm

    Apple has a code sample demonstrating how to do this:

    NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:directoryPath];
    
    NSDate *yesterday = [NSDate dateWithTimeIntervalSinceNow:(-60*60*24)];
    
    for (NSString *path in directoryEnumerator) {
    
        if ([[path pathExtension] isEqualToString:@"rtfd"]) {
            // Don't enumerate this directory.
            [directoryEnumerator skipDescendents];
        } else {
            NSDictionary *attributes = [directoryEnumerator fileAttributes];
            NSDate *lastModificationDate = [attributes objectForKey:NSFileModificationDate];
    
            if ([yesterday earlierDate:lastModificationDate] == yesterday) {
                NSLog(@"%@ was modified within the last 24 hours", path);
            }
        }
    }
    

    Basically this code enumerates the directoryPath and checks if the file or directory has been modified within the last 24 hours.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just read this requirement on a job listing: Aware of the pitfalls of
I want very specific answer from the developers who did this and want to
I have a very specific requirement to trigger _trackPageView from my C# code because
From all the articles I've read so far about Mochiweb, I've heard this over
I have a very specific requirement for interpolating nonlinear data using a 6th degree
I have to write a simple key-value store for a very specific use. This
I have recently encountered a very specific issue/requirement regarding an Android Button and ListView
This requirement is just for simplicity for developers and beautiful code. I'm building a
I realized today that I have blindly just followed this requirement for years without
Wondering if I could get some advice and direction on this following requirement: Need

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.