【问题标题】:how to find the expiry of the document in iphone/ipad如何在 iphone/ipad 中查找文档的到期时间
【发布时间】:2010-11-11 06:17:11
【问题描述】:

我正在为我的应用程序寻找 iphone/ipad 中的文档到期,我希望在特定时间段后从设备(iphone/ipad 的应用程序目录)中删除应用程序中的一个文档! 谁能帮我解决这个问题!!

【问题讨论】:

  • 我假设您说的是几天,而不是几分钟,因为您没有提及在应用程序运行时存储在设备上的文档,例如通过服务器下载或用户交互。如果我错了,请纠正我。

标签: iphone ipad nsdate nsuserdefaults nsfilemanager


【解决方案1】:

将您的“最佳之前”日期存储在 NSUserDefaults 中。当您启动应用程序时,检查当前日期与“最佳之前”。如果您的最佳使用日期已过,请删除您的文档。

NSDate *currentDate = [NSDate date];

if([currentDate laterDate:bestBeforeDate] == currentDate) {
 //delete file
 NSError *error;
 [[NSFileManager defaultManager] removeItemAtPath:YOURPATH error:&error];
}

有关将日期存储为默认值的解决方案,refer to this answer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-06
    • 2014-02-04
    • 1970-01-01
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多