0
轉換爲NSTimeInverval
時,如何將NSDocumentsDirectory
中存儲的文件的fileCreationDate
轉換爲小數點後6位的精度?如何在使用timeIntervalSince1970進行轉換時將fileCreationDate精確到6位小數?
某些代碼:
//Not accurate enough:
NSDictionary* fileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:myPhotoPath error:nil];
NSDate *creationDateOfPhoto = [fileAttribs fileCreationDate];
NSTimeInterval creationDateAsTimeInterval = [creationDateOfPhoto timeIntervalSince1970];
NSLog(@"Creation Date of Photo As Time Interval Since 1970: %f", creationDateAsTimeInterval);
//With the desired accuracy:
NSDate* now = [NSDate date];
NSTimeInterval nowStampAsTimeInterval = [now timeIntervalSince1970];
NSLog(@"Now As Time Interval Since 1970: %f", nowStampAsTimeInterval);
從該碼A輸出樣本是:
Creation Date of Photo As Time Interval Since 1970: 1373022866.000000
Now As Time Interval Since 1970: 1373022884.294028
是否有可能或者是存儲在NSDocuments的限制?
謝謝Ixt的答案。沒關係。無論如何,我只是想知道爲什麼。 –