开发者

how to find the expiry of the document in iphone/ipad

开发者 https://www.devze.com 2023-01-24 06:49 出处:网络
Im looking for expiry of the document in iphone/ipad开发者_Go百科 for my application,i want one of the document in the application to be removed from the device(application directory of iphone/ipad) a

Im looking for expiry of the document in iphone/ipad开发者_Go百科 for my application,i want one of the document in the application to be removed from the device(application directory of iphone/ipad) after particular time period!! Can any one get me the solution for that!!


Store your "best before"-date in NSUserDefaults. Check current date against "best before" when you start up the app. Delete your document if your best before date has passed.

NSDate *currentDate = [NSDate date];

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

For a solution for storing your date in the defaults, refer to this answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号