首页 > 代码库 > iOS获取应用当前Caches目录路径以及当前日期

iOS获取应用当前Caches目录路径以及当前日期

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);    NSString *path = [[paths objectAtIndex:0] stringByAppendingString:@"/hi.dat"];        [[NSFileManager defaultManager] createFileAtPath:path contents:NULL attributes:NULL];        NSURL *url = [[NSURL alloc] initFileURLWithPath:path];    NSLog(@"URL is: %@", url);    [url release];    NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0.0];    // 打印日期:中间的空格可以用‘at‘或‘T‘等字符来分隔    NSDateFormatter *dateFomatter = [[NSDateFormatter alloc] init];    [dateFomatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];    NSLog(@"Current date is: %@", [dateFomatter stringFromDate:date]);    [dateFomatter release];