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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:07:29+00:00 2026-05-27T20:07:29+00:00

In Cocoa, you can get the attributes of a file as follow NSString *path

  • 0

In Cocoa, you can get the attributes of a file as follow

NSString *path = @"/path/to/some/file";
NSError *err = ......;
NSDictionary *dic = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:&err];
NSLog(@"%@", dic);

And it will return a directory of keys, for example

{
    NSFileCreationDate = "2009-12-02 10:03:38 +0000";
    NSFileExtensionHidden = 0;
    NSFileGroupOwnerAccountID = 80;
    NSFileGroupOwnerAccountName = admin;
    NSFileHFSCreatorCode = 0;
    NSFileHFSTypeCode = 0;
    NSFileModificationDate = "2009-12-02 19:20:54 +0000";
    NSFileOwnerAccountID = 501;
    NSFileOwnerAccountName = Tony;
    NSFilePosixPermissions = 511;
    NSFileReferenceCount = 1;
    NSFileSize = 496988;
    NSFileSystemFileNumber = 5187496;
    NSFileSystemNumber = 234881029;
    NSFileType = NSFileTypeRegular;
}

Now, you can also use the CoreFoundation MDItem to get file attributes

NSString *path = @"/path/to/some/file";
MDItemRef mdItem = MDItemCreate(kCFAllocatorDefault, (__bridge CFStringRef)path);
CFArrayRef arr = MDItemCopyAttributeNames(mdItem);
CFDictionaryRef dic = MDItemCopyAttributes(mdItem, arr);
NSLog(@"%@", dic);

And it will return something like this

{
    kMDItemAuthors =     (
        "Some One"
    );
    kMDItemContentCreationDate = "2009-12-02 10:03:38 +0000";
    kMDItemContentModificationDate = "2009-12-02 19:20:54 +0000";
    kMDItemContentType = "org.openxmlformats.presentationml.presentation";
    kMDItemContentTypeTree =     (
        "org.openxmlformats.presentationml.presentation",
        "org.openxmlformats.openxml",
        "public.zip-archive",
        "com.pkware.zip-archive",
        "public.data",
        "public.item",
        "com.apple.bom-archive",
        "public.archive",
        "public.presentation",
        "public.composite-content",
        "public.content"
    );
    kMDItemDateAdded = "2011-08-16 07:52:53 +0000";
    kMDItemDisplayName = "Some File.pptx";
    kMDItemFSContentChangeDate = "2009-12-02 19:20:54 +0000";
    kMDItemFSCreationDate = "2009-12-02 10:03:38 +0000";
    kMDItemFSCreatorCode = 0;
    kMDItemFSFinderFlags = 0;
    kMDItemFSHasCustomIcon = 0;
    kMDItemFSInvisible = 0;
    kMDItemFSIsExtensionHidden = 0;
    kMDItemFSIsStationery = 0;
    kMDItemFSLabel = 0;
    kMDItemFSName = "Some File.pptx";
    kMDItemFSNodeCount = 496988;
    kMDItemFSOwnerGroupID = 80;
    kMDItemFSOwnerUserID = 501;
    kMDItemFSSize = 496988;
    kMDItemFSTypeCode = 0;
    kMDItemKind = "Microsoft PowerPoint presentation";
    kMDItemLogicalSize = 496988;
    kMDItemPhysicalSize = 499712;
    kMDItemTitle = "PowerPoint Presentation";
}

My question is, what’s the difference between these two methods of finding file attributes? There seem to be some equivalence but not all the time, which is better? And why are there these two ways anyways?

  • 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-27T20:07:29+00:00Added an answer on May 27, 2026 at 8:07 pm

    The attributes returned from NSFileManager are attributes stored on the file in the filesystem. The results from MDItemCopyAttributes are from the Spotlight index which includes most (all?) of the filesystem attributes as well as the results from any of the Spotlight plugins installed on the system.

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

Sidebar

Related Questions

how can i save a file as iwb(interactive whiteboard ) file format in cocoa.
How can i get a plain basic dialogue box in cocoa touch.seems so simple
Is it possible to set the users display picture with Cocoa? I can get
How can I get the access token from a foursquare request in cocoa? I
How can I get the current battery level using the Cocoa framework running with
How can I get the current path of my .app which is being executed
How can I get the POSIX path of the Finder window that is currently
As a continuation of this question I'm wondering if I can get some simple
In iOS and Cocoa Touch, sometimes it seems we can get by without calling
Is there an available API or functionality in cocoa where i can communicate with

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.