我想将 30 天添加到文件夹创建日期并在 30 天后阻止该应用程序。如果他们更改系统日期,我的应用程序也应该在计数后关闭。
NSDateComponents *components;
NSString *path = @"/Users/Syed/Library/Swasstik/KITSMAW0051_SWASSTIK_DB.sqlite";
BOOL isFile = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:NO];
if (isFile) {
NSLog(@"File exists");
NSDictionary* fileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];
NSDate *result = [fileAttribs fileCreationDate]; //or fileModificationDate
NSLog(@"%@",result);
NSDate* date = [NSDate date];
NSLog(@"%@", [date description]);
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
components = [gregorianCalendar components:NSDayCalendarUnit
fromDate:result
toDate:date
options:0];
[gregorianCalendar release];
NSLog(@"%ld", [components day]);
请帮我解决这个问题。提前致谢。