Permalink
Browse files

Added UIApplication category for common directory paths

  • Loading branch information...
soffes committed Sep 13, 2011
1 parent 1b2d59d commit 35cff4edded05c911e4d5e9b1ba6b950a008825a
Showing with 65 additions and 6 deletions.
  1. +41 −6 SSToolkit/UIApplication+SSToolkitAdditions.h
  2. +24 −0 SSToolkit/UIApplication+SSToolkitAdditions.m
@@ -11,13 +11,38 @@
*/
@interface UIApplication (SSToolkitAdditions)
-/** Checks for pirated application indicators.
-
- This isn't bulletproof, but should catch a lot of cases. Thanks @marcoarment: http://twitter.com/marcoarment/status/27965461020
-
- @return `YES` if the application may be pirated. `NO` if it is probably not pirated.
+///------------------
+/// @name Directories
+///------------------
+
+/**
+ Returns the file URL of the documents directory.
*/
-- (BOOL)isPirated;
+@property (nonatomic, retain, readonly) NSURL *documentsDirectoryURL;
+
+/**
+ Returns the file URL of the caches directory.
+ */
+@property (nonatomic, retain, readonly) NSURL *cachesDirectoryURL;
+
+/**
+ Returns the file URL of the downloads directory.
+ */
+@property (nonatomic, retain, readonly) NSURL *downloadsDirectoryURL;
+
+/**
+ Returns the file URL of the library directory.
+ */
+@property (nonatomic, retain, readonly) NSURL *libraryDirectoryURL;
+
+/**
+ Returns the file URL of the application support directory.
+ */
+@property (nonatomic, retain, readonly) NSURL *applicationSupportDirectoryURL;
+
+///----------------
+/// @name Utilities
+///----------------
/**
Aggregates calls to settings `networkActivityIndicatorVisible` to avoid flashing of the indicator in the status bar.
@@ -31,4 +56,14 @@
*/
- (void)setNetworkActivity:(BOOL)inProgress;
+/** Checks for pirated application indicators.
+
+ This isn't bulletproof, but should catch a lot of cases.
+
+ Thanks Marco Arment: <http://twitter.com/marcoarment/status/27965461020>
+
+ @return `YES` if the application may be pirated. `NO` if it is probably not pirated.
+ */
+- (BOOL)isPirated;
+
@end
@@ -33,6 +33,30 @@ - (void)setNetworkActivity:(BOOL)inProgress {
}
}
+
+- (NSURL *)documentsDirectoryURL {
+ return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
+}
+
+
+- (NSURL *)cachesDirectoryURL {
+ return [[[NSFileManager defaultManager] URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask] lastObject];
+}
+
+- (NSURL *)downloadsDirectoryURL {
+ return [[[NSFileManager defaultManager] URLsForDirectory:NSDownloadsDirectory inDomains:NSUserDomainMask] lastObject];
+}
+
+
+- (NSURL *)libraryDirectoryURL {
+ return [[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
+}
+
+
+- (NSURL *)applicationSupportDirectoryURL {
+ return [[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject];
+}
+
@end

0 comments on commit 35cff4e

Please sign in to comment.