Skip to content

Commit

Permalink
Added UIApplication category for common directory paths
Browse files Browse the repository at this point in the history
  • Loading branch information
soffes committed Sep 13, 2011
1 parent 1b2d59d commit 35cff4e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 6 deletions.
47 changes: 41 additions & 6 deletions SSToolkit/UIApplication+SSToolkitAdditions.h
Expand Up @@ -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.
Expand All @@ -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
24 changes: 24 additions & 0 deletions SSToolkit/UIApplication+SSToolkitAdditions.m
Expand Up @@ -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


Expand Down

0 comments on commit 35cff4e

Please sign in to comment.