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 389167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:50:26+00:00 2026-05-12T15:50:26+00:00

I am just learning Objective-C / Cocoa and I am a little unsure how

  • 0

I am just learning Objective-C / Cocoa and I am a little unsure how I might extend my code to display the size of the files found.

EDIT 2

I have taken the comments from SMorgan & Peter below and worked them into the code … comments most welcome.

// ------------------------------------------------------------------- **
// DISC: FILEWALKER ..... (cocoa_fileWalker.m)
// DATE: 28th September 2009
// DESC: List all "*.exr" files in specified directory
// ------------------------------------------------------------------- **

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSString *fileName;
    NSDictionary *attrDir;
    NSError *myError;
    NSNumber *fileSize;
    NSFileManager *manager = [NSFileManager defaultManager];
    NSString *rootPath = [@"~/Pictures" stringByExpandingTildeInPath];
    NSMutableArray *fileArray = [[NSMutableArray alloc] init];
    NSMutableString *newPath = [[NSMutableString alloc] init];

    NSLog(@"Home: %@",rootPath);

    for(fileName in [manager enumeratorAtPath:rootPath]){
        if ([[fileName pathExtension] isEqual:@"exr"]) {
            [fileArray addObject:fileName];

            [newPath setString:rootPath];
            [newPath appendString:@"/"];
            [newPath appendString:fileName];
            attrDir = [manager attributesOfItemAtPath:newPath error:&myError];
            fileSize = [attrDir objectForKey: @"NSFileSize"];
            NSLog(@"File: /%@ Size: %@", fileName, fileSize);
        }
    }

    [fileArray release];
    [newPath release];
    [pool drain];
    return 0;
}
// ------------------------------------------------------------------- **

cheers gary

  • 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-05-12T15:50:26+00:00Added an answer on May 12, 2026 at 3:50 pm

    You would use -[NSFileManager fileAttributesAtPath:traverseLink:] (or if you are only targeting 10.5+, -[NSFileManager attributesOfItemAtPath:error:]), and then read the NSFileSize from the returned dictionary.

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

Sidebar

Related Questions

I am just learning objective-C, and have a book with code like this: NSArray
I just started learning objective c. I have this little problems and questions, hope
I have just started learning Objective-C / Cocoa Touch. I am working on an
I've just started learning Objective-C and made a little compass app that will display
Just learning C#, radiobuttons and checkboxes. No urgency. The code works to display the
I'm just learning some basic programming in Objective C and Cocoa. I'm trying to
I am just learning objective-c but can't figure out whats wrong with my code
I'm just learning Cocos2d and Objective-C, and I have some problems with touch detection.
I just started learning Objective-C and OOP ... so I have very stupid question
I have just started learning Objective-C, I am reading Programming in Objective-C 3rd Edition

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.