Skip to content
Browse files

Added -pathForDocuments_ph that gets the path to the (writable) Docum…

…ents folder from the bundle. It's more convenient that way, since iOS apps are sandboxed.
  • Loading branch information...
1 parent 1bc1d56 commit 18feea3bd6b40260a31eafb1378c94dd17f51fbb @philippec committed Aug 17, 2011
Showing with 11 additions and 0 deletions.
  1. +1 −0 categories/NSBundleAdditions.h
  2. +10 −0 categories/NSBundleAdditions.m
View
1 categories/NSBundleAdditions.h
@@ -13,6 +13,7 @@
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 20000
- (NSString*) pathForResource_ph: (NSString*) name ofType: (NSString*) ext;
+- (NSString*) pathForDocument_ph: (NSString*) name ofType: (NSString*) ext;
#endif
@end
View
10 categories/NSBundleAdditions.m
@@ -20,6 +20,16 @@ - (NSString*) pathForResource_ph: (NSString*) name ofType: (NSString*) ext
NSString *bndlResPath = [self resourcePath];
return [bndlResPath stringByAppendingPathComponent: resPath];
}
+- (NSString*) pathForDocument_ph: (NSString*) name ofType: (NSString*) ext
+{
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *docPath = [paths objectAtIndex: 0];
+
+ NSString *resPath = name;
+ if (ext != nil)
+ resPath = [name stringByAppendingPathExtension: ext];
+ return [docPath stringByAppendingPathComponent: resPath];
+}
#endif
@end

0 comments on commit 18feea3

Please sign in to comment.
Something went wrong with that request. Please try again.