summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2016-08-23 10:25:21 -0400
committerJoel Fischer <joeljfischer@gmail.com>2016-08-23 10:28:30 -0400
commit706ea518056c031f0c5b4c70a2c9de3506f73f18 (patch)
treee947b6e7be0741242c73e2ceffa05c21524e6b37
parent269d619ae8d3e26304b8b7a975cdd40004c31072 (diff)
downloadsdl_ios-706ea518056c031f0c5b4c70a2c9de3506f73f18.tar.gz
Remove “ephemeral” from SDLFile class initializers
* Minor clarity updates
-rw-r--r--SmartDeviceLink/SDLFile.h10
-rw-r--r--SmartDeviceLink/SDLFile.m13
-rw-r--r--SmartDeviceLink/SDLListFilesOperation.m3
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.m10
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m4
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m2
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m2
7 files changed, 21 insertions, 23 deletions
diff --git a/SmartDeviceLink/SDLFile.h b/SmartDeviceLink/SDLFile.h
index 520c1e1a1..3995f6722 100644
--- a/SmartDeviceLink/SDLFile.h
+++ b/SmartDeviceLink/SDLFile.h
@@ -36,12 +36,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (copy, nonatomic, readonly, nullable) NSURL *fileURL;
/**
- * The binary data of the local file.
+ * The binary data of the SDLFile. If initialized with data, this will be a relatively quick call, but if initialized with a file URL, this is a rather expensive call the first time. The data will be cached in RAM after the first call.
*/
@property (copy, nonatomic, readonly) NSData *data;
/**
- * Unless set manually, the system will attempt to determine the type of file that you have passed in. It will default to BINARY if it does not recognize the file type or the file type is not supported by SDL.
+ * The system will attempt to determine the type of file that you have passed in. It will default to BINARY if it does not recognize the file type or the file type is not supported by SDL.
*/
@property (strong, nonatomic, readonly) SDLFileType *fileType;
@@ -84,12 +84,12 @@ NS_ASSUME_NONNULL_BEGIN
*
* @warning If this is not a readable file, this will return nil
*
- * @param url The url to the file that will be uploaded
+ * @param url The url to the file on disk that will be uploaded
* @param name The name of the file that will be used to reference the file in the future (for example on the remote file system).
*
* @return An instance of this class, or nil if a readable file at the url could not be found.
*/
-+ (instancetype)ephemeralFileAtFileURL:(NSURL *)url name:(NSString *)name;
++ (instancetype)fileAtFileURL:(NSURL *)url name:(NSString *)name;
/**
* Create an SDL file using raw data. It is strongly preferred to pass a file URL instead of data, as it is currently held in memory until the file is sent.
@@ -127,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @return An instance of this class
*/
-+ (instancetype)ephemeralFileWithData:(NSData *)data name:(NSString *)name fileExtension:(NSString *)extension;
++ (instancetype)fileWithData:(NSData *)data name:(NSString *)name fileExtension:(NSString *)extension;
@end
diff --git a/SmartDeviceLink/SDLFile.m b/SmartDeviceLink/SDLFile.m
index b6ef0c9d2..2b814329d 100644
--- a/SmartDeviceLink/SDLFile.m
+++ b/SmartDeviceLink/SDLFile.m
@@ -55,7 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
return [[self alloc] initWithFileURL:url name:name persistent:YES];
}
-+ (instancetype)ephemeralFileAtFileURL:(NSURL *)url name:(NSString *)name {
++ (instancetype)fileAtFileURL:(NSURL *)url name:(NSString *)name {
return [[self alloc] initWithFileURL:url name:name persistent:NO];
}
@@ -69,13 +69,12 @@ NS_ASSUME_NONNULL_BEGIN
}
_fileURL = nil;
+ _data = data;
_name = name;
_persistent = persistent;
_fileType = [self.class sdl_fileTypeFromFileExtension:extension];
_overwrite = NO;
- _data = data;
-
return self;
}
@@ -83,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN
return [[self alloc] initWithData:data name:name fileExtension:extension persistent:YES];
}
-+ (instancetype)ephemeralFileWithData:(NSData *)data name:(NSString *)name fileExtension:(NSString *)extension {
++ (instancetype)fileWithData:(NSData *)data name:(NSString *)name fileExtension:(NSString *)extension {
return [[self alloc] initWithData:data name:name fileExtension:extension persistent:NO];
}
@@ -92,10 +91,10 @@ NS_ASSUME_NONNULL_BEGIN
- (NSData *)data {
if (_data.length == 0 && _fileURL != nil) {
- return [NSData dataWithContentsOfURL:_fileURL];
- } else {
- return _data;
+ _data = [NSData dataWithContentsOfURL:_fileURL];
}
+
+ return _data;
}
diff --git a/SmartDeviceLink/SDLListFilesOperation.m b/SmartDeviceLink/SDLListFilesOperation.m
index 490de9ea5..537eadbb5 100644
--- a/SmartDeviceLink/SDLListFilesOperation.m
+++ b/SmartDeviceLink/SDLListFilesOperation.m
@@ -11,7 +11,6 @@
#import "SDLConnectionManagerType.h"
#import "SDLListFiles.h"
#import "SDLListFilesResponse.h"
-#import "SDLRPCRequestFactory.h"
NS_ASSUME_NONNULL_BEGIN
@@ -58,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)sdl_listFiles {
- SDLListFiles *listFiles = [SDLRPCRequestFactory buildListFilesWithCorrelationID:@0];
+ SDLListFiles *listFiles = [[SDLListFiles alloc] init];
__weak typeof(self) weakSelf = self;
[self.connectionManager sendManagerRequest:listFiles
diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m
index 1f762acc8..b39fd2160 100644
--- a/SmartDeviceLink/SDLLockScreenManager.m
+++ b/SmartDeviceLink/SDLLockScreenManager.m
@@ -57,17 +57,17 @@ NS_ASSUME_NONNULL_BEGIN
} else if (self.config.customViewController != nil) {
self.presenter.viewController = self.config.customViewController;
} else {
- SDLLockScreenViewController *lockScreenVC = nil;
+ SDLLockScreenViewController *viewController = nil;
@try {
- lockScreenVC = [[UIStoryboard storyboardWithName:@"SDLLockScreen" bundle:[NSBundle bundleForClass:[self class]]] instantiateInitialViewController];
+ viewController = [[UIStoryboard storyboardWithName:@"SDLLockScreen" bundle:[NSBundle bundleForClass:[self class]]] instantiateInitialViewController];
} @catch (NSException *exception) {
[SDLDebugTool logInfo:@"SDL Error: Attempted to instantiate the default SDL Lock Screen and could not find the storyboard. Be sure the 'SmartDeviceLink' bundle is within your main bundle. We're just going to return without instantiating the lock screen."];
return;
}
- lockScreenVC.appIcon = self.config.appIcon;
- lockScreenVC.backgroundColor = self.config.backgroundColor;
- self.presenter.viewController = lockScreenVC;
+ viewController.appIcon = self.config.appIcon;
+ viewController.backgroundColor = self.config.backgroundColor;
+ self.presenter.viewController = viewController;
}
self.canPresent = YES;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
index 0c720e4cb..8b3d3d7db 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileManagerSpec.m
@@ -184,7 +184,7 @@ describe(@"SDLFileManager", ^{
beforeEach(^{
testFileName = [testInitialFileNames anyObject];
testFileData = [@"someData" dataUsingEncoding:NSUTF8StringEncoding];
- testUploadFile = [SDLFile ephemeralFileWithData:testFileData name:testFileName fileExtension:@"bin"];
+ testUploadFile = [SDLFile fileWithData:testFileData name:testFileName fileExtension:@"bin"];
});
context(@"when the file's overwrite property is YES", ^{
@@ -316,7 +316,7 @@ describe(@"SDLFileManager", ^{
beforeEach(^{
testFileName = @"not a test file";
testFileData = [@"someData" dataUsingEncoding:NSUTF8StringEncoding];
- testUploadFile = [SDLFile ephemeralFileWithData:testFileData name:testFileName fileExtension:@"bin"];
+ testUploadFile = [SDLFile fileWithData:testFileData name:testFileName fileExtension:@"bin"];
[testFileManager uploadFile:testUploadFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) {
completionSuccess = success;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m
index 9512cd7e8..0e32c0f9f 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFileSpec.m
@@ -74,7 +74,7 @@ describe(@"SDLFile", ^{
testFileURL = [testBundle URLForResource:@"testImageJPG" withExtension:@"jpg"];
testFileName = @"someImage";
- testFile = [SDLFile ephemeralFileAtFileURL:testFileURL name:testFileName];
+ testFile = [SDLFile fileAtFileURL:testFileURL name:testFileName];
});
it(@"should correctly store data", ^{
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
index 58c836988..6e84e0674 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
@@ -27,7 +27,7 @@ describe(@"Upload File Operation", ^{
beforeEach(^{
testFileName = @"test file";
testFileData = [@"test1234" dataUsingEncoding:NSUTF8StringEncoding];
- testFile = [SDLFile ephemeralFileWithData:testFileData name:testFileName fileExtension:@"bin"];
+ testFile = [SDLFile fileWithData:testFileData name:testFileName fileExtension:@"bin"];
testFileWrapper = [SDLFileWrapper wrapperWithFile:testFile completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) {
successResult = success;
bytesAvailableResult = bytesAvailable;