Created
June 8, 2012 21:18
-
-
Save flipjorge/2898166 to your computer and use it in GitHub Desktop.
iOS Directories paths helper
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> | |
@interface Directory : NSObject | |
+(NSString*)documents; | |
+(NSString*)temp; | |
+(NSString*)library; | |
+(NSString*)bundle; | |
+(NSString*)cache; | |
+(NSString*)preferences; | |
@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 "Directory.h" | |
@implementation Directory | |
+(NSString*)documents | |
{ | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *path = [paths objectAtIndex:0]; | |
return path; | |
} | |
+(NSString*)temp | |
{ | |
return NSTemporaryDirectory(); | |
} | |
+(NSString*)library | |
{ | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); | |
NSString *path = [paths objectAtIndex:0]; | |
return path; | |
} | |
+(NSString*)bundle | |
{ | |
return [[NSBundle mainBundle] bundlePath]; | |
} | |
+(NSString*)cache | |
{ | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); | |
NSString *path = [paths objectAtIndex:0]; | |
return path; | |
} | |
+(NSString*)preferences | |
{ | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSUserDomainMask, YES); | |
NSString *path = [paths objectAtIndex:0]; | |
return path; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment