iOS File Management

Retrieve the path for an application

NSArray *NSSearchPathForDirectoriesInDomains(
NSSearchPathDirectory directory,
NSSearchPathDomainMask domainMask,
BOOL expandTilde
);

[returnResult lastObject];
  • Use lastObject to get the path

iOS File Manager: NSFileManager

File Management Objects and APIs

NSFileManager *manager = [[NSFileManager alloc] init];
- (BOOL)createDirectoryAtPath:(NSString *)path
    withIntermediateDirectories:(BOOL)createIntermediates
                     attributes:(NSDictionary*)attributes
                          error:(NSError **)error;
- (BOOL)isReadableFileAtPath:(NSString *)path;
- (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error;

Path, reading/writing strings to files API with NSString

- (NSString *)stringByAppendingPathComponent:(NSString *)component;
- (NSString *)stringByDeletingLastPathComponent;
- (BOOL)writeToFile:(NSString *)path
         atomically:(BOOL)flag
           encoding:(NSStringEncoding)encoding
              error:(NSError **)error;
- (NSString *)stringWithContentsOfFile:(NSString *)path
                          usedEncoding:(NSStringEncoding *)encoding
                                 error:(NSError **)error;