Created
February 12, 2013 03:23
-
-
Save derektu/4760007 to your computer and use it in GitHub Desktop.
Provide Documents path related API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
// Provides Path undrer "Documents" | |
// | |
@interface DocumentPathBuilder : NSObject | |
@property (nonatomic, copy, readonly) NSString* documentFolder; | |
// Given a 'relative' filePath, return its absolute path under documents folder | |
// | |
- (NSString*) getFullPath:(NSString*)filePath; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "DocumentPathBuilder.h" | |
- (id)init | |
{ | |
self = [super init]; | |
if (self) | |
{ | |
// initialize document folder property | |
_documentFolder = [self getDocumentFolder]; | |
} | |
return self; | |
} | |
- (NSString*)getDocumentFolder | |
{ | |
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
return paths[0]; | |
} | |
- (NSString*)getFullPath:(NSString*)filePath | |
{ | |
return [self.documentFolder stringByAppendingPathComponent:filePath]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment