iOS-Data

Mantle FMDB

App 沙盒(sandbox)

  • ./application
    • Document [syn]
    • Library
  • | + Caches
    | + Preferences [syn]
    • tmp
1
2
3
4
5
6
7
8
9
10
11
12
13
NSString *homeDirectory = NSHomeDirectory(); //沙盒根目录
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documnet = paths.firstObject;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *library = paths.firstObject;
NSString *tmpDir = NSTemporaryDirectory();
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *caches = paths.firstObject;
NSBundle *applicationBundle = [NSBundle mainBundle];
NSString *path = [applicationBundle pathForResource:@"myfile" ofType:@"type"];
NSFileManager *fileManager = [NSFileManager defaultManager];

-

-

NSuserDefaults

基础类型,NSString, NSData, NSArrary, NSDictory, NSURL

plist

A property list is a representation of a hierarchy of objects that can be stored in the file system and reconstituted later. Property lists give applications a lightweight and portable way to store small amounts of data.

1
2
3
4
5
//NSDictory
- (nullable NSDictionary<KeyType, ObjectType> *)initWithContentsOfFile:(NSString *)path;
//NSArrary NSData
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile;
... ...