diff options
Diffstat (limited to 'Classes')
| -rw-r--r-- | Classes/NSFileManager+DirectoryLocations.h | 17 | ||||
| -rw-r--r-- | Classes/NSFileManager+DirectoryLocations.m | 18 |
2 files changed, 35 insertions, 0 deletions
diff --git a/Classes/NSFileManager+DirectoryLocations.h b/Classes/NSFileManager+DirectoryLocations.h new file mode 100644 index 0000000..6c42204 --- /dev/null +++ b/Classes/NSFileManager+DirectoryLocations.h @@ -0,0 +1,17 @@ +// Based off of Matt Gallagher's 10.5+ category from: +// http://cocoawithlove.com/2010/05/finding-or-creating-application-support.html +// +// Actual function code taken from Hasani Hunter: +// http://www.cocoabuilder.com/archive/cocoa/190500-saving-to-application-support-folder.html#190506 + +#import <Foundation/Foundation.h> + +// +// DirectoryLocations is a set of global methods for finding the fixed location +// directories. +// +@interface NSFileManager (DirectoryLocations) + +- (NSString *)applicationSupportDirectory; + +@end diff --git a/Classes/NSFileManager+DirectoryLocations.m b/Classes/NSFileManager+DirectoryLocations.m new file mode 100644 index 0000000..84cf307 --- /dev/null +++ b/Classes/NSFileManager+DirectoryLocations.m @@ -0,0 +1,18 @@ +#import "NSFileManager+DirectoryLocations.h" + +@implementation NSFileManager (DirectoryLocations) + +/** + Returns the support folder for the application, used to store the Core Data + store file. This code uses a folder named _ApplicationName_ for + the content, either in the NSApplicationSupportDirectory location or (if the + former cannot be found), the system's temporary directory. + */ + +- (NSString *)applicationSupportDirectory { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex: 0] : NSTemporaryDirectory(); + return [basePath stringByAppendingPathComponent:@"On Task"]; +} + +@end |
