Get EXEC_BAD_ACCESS when I get the NSFileModificationDate
Posted
by Toto
on Stack Overflow
See other posts from Stack Overflow
or by Toto
Published on 2010-03-24T13:19:11Z
Indexed on
2010/03/24
13:23 UTC
Read the original article
Hit count: 327
Hi everyone,
I try to get the last modification date of a file:
NSFileManager *fm = [[NSFileManager alloc] init];
NSError *err;
NSDate *lastModif = [[fm attributesOfItemAtPath:filename error:&err] objectForKey:NSFileModificationDate];//filename is ok ;-)
if(err == nil) {
[lastModif retain];
//I can put a NSLog of lastModif here, it works !!
NSTimeInterval lastModifDiff = [lastModif timeIntervalSinceNow];//crash here
}
I don't understand why the NSDate seems to be released, why the retain does not retain it.
Thank you if you have any idea...
© Stack Overflow or respective owner