口袋版本的一折买

YZMAHistoryTool.m 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // YZMAHistoryTool.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/2/1.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "YZMAHistoryTool.h"
  9. @implementation YZMAHistoryTool
  10. + (NSString *)getHistoryFilePath
  11. {
  12. //1. 创建一个plist文件
  13. NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
  14. NSString *path=[paths objectAtIndex:0];
  15. // NSLog(@"path = %@",path);
  16. NSString *filename=[path stringByAppendingPathComponent:@"HistoryRecord.plist"];
  17. NSFileManager* fm = [NSFileManager defaultManager];
  18. if (![fm fileExistsAtPath:filename]) {
  19. [fm createFileAtPath:filename contents:nil attributes:nil];
  20. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  21. [dict setObject:@[] forKey:@"historyArr"];
  22. [dict writeToFile:filename atomically:YES];
  23. }
  24. return filename;
  25. }
  26. + (NSString *)getJsonDataFilePath
  27. {
  28. //1. 创建一个plist文件
  29. NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
  30. NSString *path=[paths objectAtIndex:0];
  31. // NSLog(@"path = %@",path);
  32. NSString *filename=[path stringByAppendingPathComponent:@"JsonData.plist"];
  33. NSFileManager* fm = [NSFileManager defaultManager];
  34. if (![fm fileExistsAtPath:filename]) {
  35. [fm createFileAtPath:filename contents:nil attributes:nil];
  36. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  37. [dict setObject:@[] forKey:@"JsonData"];
  38. [dict writeToFile:filename atomically:YES];
  39. }
  40. return filename;
  41. }
  42. @end