Andrew Johnson
Andrew Johnson

Reputation: 13286

Can't get FileCreationDate?

In my app, I create a directory, and then the following code works:

NSDictionary *fileAttributes = [fileManager fileAttributesAtPath:trackDirectory traverseLink:YES];
NSDate *fileDate = [fileAttributes objectForKey:NSFileModificationDate];

However, when I try and get the NSFileCreationDate instead, it doesn't work.

What am I doing wrong?

Upvotes: 2

Views: 1321

Answers (3)

Paresh Navadiya
Paresh Navadiya

Reputation: 38239

It depends on iOS version. iOS 5 provides following detail 
{
  NSFileCreationDate = "2012-05-14 09:59:24 +0000";
  NSFileExtensionHidden = 0;
  NSFileGroupOwnerAccountID = 20;
  NSFileGroupOwnerAccountName = staff;
  NSFileModificationDate = "2012-05-14 09:59:29 +0000";
  NSFileOwnerAccountID = 501;
  NSFileOwnerAccountName = indianic;
  NSFilePosixPermissions = 420;
  NSFileReferenceCount = 1;
  NSFileSize = 464357;
  NSFileSystemFileNumber = 1732968;
  NSFileSystemNumber = 234881027;
  NSFileType = NSFileTypeRegular;
}

Upvotes: 0

Mihai Timar
Mihai Timar

Reputation: 1160

Not sure when it was added exactly, but it depends on iOS version. I have tested this in iOS 4.1 and got:

{
    NSFileCreationDate = "2011-09-23 07:20:12 GMT";
    NSFileExtensionHidden = 0;
    NSFileGroupOwnerAccountID = 501;
    NSFileGroupOwnerAccountName = mobile;
    NSFileModificationDate = "2011-09-23 07:20:48 GMT";
    NSFileOwnerAccountID = 501;
    NSFileOwnerAccountName = mobile;
    NSFilePosixPermissions = 420;
    NSFileProtectionKey = NSFileProtectionNone;
    NSFileReferenceCount = 1;
    NSFileSize = 634880;
    NSFileSystemFileNumber = 382807;
    NSFileSystemNumber = 234881027;
    NSFileType = NSFileTypeRegular;
}

Upvotes: 1

ohhorob
ohhorob

Reputation: 11805

As far as I can see, there is no other date on iPhoneOS. Here is what the whole attributesOfItemAtPath: looks like:

{
    NSFileGroupOwnerAccountID = 20;
    NSFileGroupOwnerAccountName = staff;
    NSFileModificationDate = 2009-12-03 21:34:59 -0800;
    NSFileOwnerAccountID = 501;
    NSFileOwnerAccountName = username;
    NSFilePosixPermissions = 420;
    NSFileReferenceCount = 1;
    NSFileSize = 8703;
    NSFileSystemFileNumber = 14066295;
    NSFileSystemNumber = 234881026;
    NSFileType = NSFileTypeRegular;
}

So, your answer is.. you're trying to access a dictionary key that is not present on iPhoneOS.

Upvotes: 1

Related Questions