forked from jonataslaw/VideoCompress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dhitiwatAgoda/swift-to-objc
Convert Swift to ObjC code with minimum functionality
- Loading branch information
Showing
6 changed files
with
156 additions
and
359 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface Utility : NSObject | ||
|
||
+ (NSString *)basePath; | ||
|
||
+ (NSString *)excludeFileProtocol:(NSString *)path; | ||
|
||
+ (NSURL *)getPathUrl:(NSString *)path; | ||
|
||
+ (NSString *)getFileName:(NSString *)path; | ||
|
||
+ (void)deleteFile:(NSString *)path; | ||
|
||
+ (NSString *)keyValueToJson:(NSDictionary *)keyAndValue; | ||
|
||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#import "Utility.h" | ||
|
||
@implementation Utility | ||
|
||
+ (NSString *)basePath { | ||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
|
||
NSString *tempPath = NSTemporaryDirectory(); | ||
NSString *path = [tempPath stringByAppendingString:@"video_compress"]; | ||
|
||
if (![fileManager fileExistsAtPath:path]){ | ||
[fileManager createDirectoryAtPath:path withIntermediateDirectories:true attributes:nil error:nil]; | ||
} | ||
return path; | ||
} | ||
|
||
+ (NSString *)excludeFileProtocol:(NSString *)path { | ||
return [path stringByReplacingOccurrencesOfString:@"file://" withString:@""]; | ||
} | ||
|
||
+ (NSURL *)getPathUrl:(NSString *)path { | ||
return [NSURL fileURLWithPath:[self excludeFileProtocol:path]]; | ||
} | ||
|
||
+ (NSString *)getFileName:(NSString *)path { | ||
return [[path lastPathComponent] stringByDeletingPathExtension]; | ||
} | ||
|
||
+ (void)deleteFile:(NSString *)path { | ||
NSFileManager *fileManager = [NSFileManager defaultManager]; | ||
NSURL *url = [self getPathUrl:path]; | ||
[fileManager removeItemAtURL:url error:nil]; | ||
} | ||
|
||
+ (NSString *)keyValueToJson:(NSDictionary *)keyAndValue { | ||
NSData *data = [NSJSONSerialization dataWithJSONObject:keyAndValue options:NSJSONWritingFragmentsAllowed error:nil]; | ||
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
@end |
Oops, something went wrong.