Last active
August 29, 2015 14:01
-
-
Save 2bbb/b9256592401f21e2747a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @interface NSString (AnotherClassExtension) | |
| - (NSURL *)toURL; | |
| - (NSURL *)toFileURL; | |
| - (NSString *)toDocumentDirectoryPath; | |
| - (NSURL *)toDocumentDirectoryFileURL; | |
| - (NSString *)toCachePath; | |
| - (NSURL *)toCacheFileURL; | |
| - (UIImage* *)toImage; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @implementation NSString (AnotherClassExtension) | |
| - (NSURL *)toURL { | |
| return [NSURL URLWithString:self]; | |
| } | |
| - (NSURL *)toFileURL { | |
| return [NSURL fileURLWithPath:self]; | |
| } | |
| - (NSString *)toDocumentDirectoryPath { | |
| NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
| NSString *dir = paths[0]; | |
| return [dir stringByAppendingPathComponent:self]; | |
| } | |
| - (NSURL *)toDocumentDirectoryFileURL { | |
| return self.toDocumentDirectoryPath.toFileURL; | |
| } | |
| - (NSString *)toCachePath { | |
| NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); | |
| NSString *dir = paths[0]; | |
| return [dir stringByAppendingPathComponent:self]; | |
| } | |
| - (NSURL *)toCacheFileURL { | |
| return self.toCachePath.toURL; | |
| } | |
| - (UIImage* *)toImage { | |
| return [UIImage imageNamed:self]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment