ebs*_*bsp 13 iphone xcode cocoa objective-c
我的应用程序数据中有一个plist文件,我想每24小时从网络服务器更新一次.有没有办法检查文件上次修改的时间,或者我应该以某种方式注册更新文件的日期和时间,并使用它来比较?
if (lastMod > currentDate){
[arrayFromXml writeToFile:path atomically:YES];
}
Run Code Online (Sandbox Code Playgroud)
Ric*_*III 45
您可以使用NSFileManager:
NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:@"path/to/my/file" error:nil];
NSDate *date = [attributes fileModificationDate];
// compare 'date'
// date > now
if ([date compareTo:[NSDate date]] == 1)
{
[arrayFromXML writeToFile:@"path/to/my/file" atomically:YES];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11052 次 |
| 最近记录: |