Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieve file creation or modification date
    primarykey
    data
    text
    <p>I'm using this piece of code to try to retrieve the last modified date of a file:</p> <pre><code>NSError *error = nil; NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath: myFilePath error:&amp;error]; if (attributes != nil) { NSDate *date = (NSDate*)[attributes objectForKey: NSFileModificationDate]; NSLog(@"Date modiifed: %@", [date description]); } else { NSLog(@"Not found"); } </code></pre> <p>This works well for files in the main bundle but not if the file is located in a subdirectory of the app's document folder, with <code>myFilePath</code> like this:</p> <pre><code>/Users/User/Library/Application Support/iPhone Simulator/6.0/Applications/The App ID Number/Documents/mySubdirectory/My Saved File </code></pre> <p>It keeps returning "not found".</p> <p>I know the file is there, as I can view it with finder. I also tried removing the spaces in the file name but this had no effect.</p> <p>The error log says no such file or directory, so it looks like something must've gone wrong when I tried to copy the file to the document directory. </p> <p>Weird thing is, iterating through the document sub directory with <code>contentsOfDirectoryAtPath</code> shows the file as being present.</p> <p>I've tried hard-coding the path and retrieving it programmatically, with:</p> <pre><code>*myFolder = [documentsDirectory stringByAppendingPathComponent:@"myFolder"]; *myFilePath = [myFolder stringByAppendingPathComponent:theFileName]; </code></pre> <p>Can anyone see where I'm going wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload