大佬教程收集整理的这篇文章主要介绍了objective-c – 在Cocoa中查找文件的上次访问日期,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
struct stat output; //int ret = stat([[[openPanel filenames] lastObject] UTF8String],&output); int ret = stat([[[openPanel filenames] lastObject] fileSystemRepresentation],&output); // error handling omitted for this example struct timespec accessTime = output.st_atimespec; NSDate *aDate = [NSDate dateWithTimeIntervalSince1970:accessTime.tv_sec]; NSLog(@"Access Time %d,%@",ret,aDatE);
根据上面的代码,我尝试了UTF8String和fileSystemRepresentation,但两者都给了我当前的日期和时间.如果我做错了,请告诉我.
例如
struct stat output; int ret = stat(aFilePath,&output); // error handling omitted for this example struct timespec accessTime = output.st_atime;
您应该通过将-fileSystemRepresentation发送到包含该路径的NSString来获取aFilePath.
另一种获得所需方法的方法是在指向所需文件的文件URL之前构造NSURL,并使用-resourceValuesForKeys:error:获取NSURLContentAccessDate资源值.
以上是大佬教程为你收集整理的objective-c – 在Cocoa中查找文件的上次访问日期全部内容,希望文章能够帮你解决objective-c – 在Cocoa中查找文件的上次访问日期所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。