diff options
| author | Teddy Wing | 2012-07-20 23:36:36 -0400 |
|---|---|---|
| committer | Teddy Wing | 2012-07-20 23:36:36 -0400 |
| commit | 8575b4fe4e7283383154dc5ac016fcfe042dcb56 (patch) | |
| tree | 48b3b8591382a82a3b48cc84271cf03da56cdc16 /Classes | |
| parent | 7720dba1e726bdf91a6ae4191fe39285eeb1dee3 (diff) | |
| download | On-Task-8575b4fe4e7283383154dc5ac016fcfe042dcb56.tar.bz2 | |
New version of ApplicationSupport directory -finder.
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 |
