0

Im looking for expiry of the document in iphone/ipad 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!!

MrSmith42
  • 9,961
  • 6
  • 38
  • 49
siva
  • 1,402
  • 2
  • 14
  • 28
  • I am assuming you are talking days, not minutes, since you make no mention of the document being stored on the device while the app is running, e.g. through a server download or user interaction. Please correct me if I am wrong. – Joseph Tura Nov 11 '10 at 08:41

1 Answers1

0

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.

Community
  • 1
  • 1
Joseph Tura
  • 6,290
  • 8
  • 47
  • 73