From 916f058d834b159269e56b070e5d069f4e440a10 Mon Sep 17 00:00:00 2001 From: Dov Frankel Date: Tue, 2 Jul 2019 22:28:21 -0400 Subject: [PATCH] Deprecated file path initializers in favor of URL initializers (Issue #93) --- CHANGELOG.md | 1 + Source/UZKArchive.h | 8 ++++---- Tests/WriteDataTests.swift | 4 ++-- beta-notes.md | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a5e37e..a9bdf5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Removed methods deprecated in v1.9 (Issue #90, PR #92) * Fixed behavior of `-extractFilesTo:overwrite:error:`, so it shows the progress of each individual file as they extract (Issue #91, PR #94) +* Deprecated the initializers that take a file path instead of an `NSURL` (Issue #90, PR #95) ## 1.9 diff --git a/Source/UZKArchive.h b/Source/UZKArchive.h index 2f54582..81c4619 100644 --- a/Source/UZKArchive.h +++ b/Source/UZKArchive.h @@ -179,14 +179,14 @@ extern NSString *UZKErrorDomain; /** - * Creates and returns an archive at the given path + * DEPRECATED: Creates and returns an archive at the given path * * @param filePath A path to the archive file * @param error Returns an error code if the object can't be initialized * * @return Returns a UZKArchive object, or nil if the path isn't reachable */ -- (nullable instancetype)initWithPath:(NSString *)filePath error:(NSError **)error; +- (nullable instancetype)initWithPath:(NSString *)filePath error:(NSError **)error __deprecated_msg("Use -initWithURL:error: instead"); /** * Creates and returns an archive at the given URL @@ -199,7 +199,7 @@ extern NSString *UZKErrorDomain; - (nullable instancetype)initWithURL:(NSURL *)fileURL error:(NSError **)error; /** - * Creates and returns an archive at the given path, with a given password + * DEPRECATED: Creates and returns an archive at the given path, with a given password * * @param filePath A path to the archive file * @param password The password of the given archive @@ -207,7 +207,7 @@ extern NSString *UZKErrorDomain; * * @return Returns a UZKArchive object, or nil if the path isn't reachable */ -- (nullable instancetype)initWithPath:(NSString *)filePath password:(nullable NSString *)password error:(NSError **)error; +- (nullable instancetype)initWithPath:(NSString *)filePath password:(nullable NSString *)password error:(NSError **)error __deprecated_msg("Use -initWithURL:password:error: instead"); /** * Creates and returns an archive at the given URL, with a given password diff --git a/Tests/WriteDataTests.swift b/Tests/WriteDataTests.swift index 64f3ff8..f265bf6 100644 --- a/Tests/WriteDataTests.swift +++ b/Tests/WriteDataTests.swift @@ -383,7 +383,7 @@ class WriteDataTests: UZKArchiveTestCase { let testArchiveURL = tempDirectory.appendingPathComponent("SwiftWriteDataTest.zip") let password = "111111" - let writeArchive = try! UZKArchive(path: testArchiveURL.path, password: password) + let writeArchive = try! UZKArchive(url: testArchiveURL, password: password) for testFilePath in testFilePaths { let fileData = try? Data(contentsOf: testFileURLs[testFilePath] as! URL) @@ -398,7 +398,7 @@ class WriteDataTests: UZKArchiveTestCase { // Read with UnzipKit - let readArchive = try! UZKArchive(path: testArchiveURL.path, password: password) + let readArchive = try! UZKArchive(url: testArchiveURL, password: password) XCTAssertTrue(readArchive.isPasswordProtected(), "Archive is not marked as password-protected") var index = 0 diff --git a/beta-notes.md b/beta-notes.md index 1825edb..5b6bbcd 100644 --- a/beta-notes.md +++ b/beta-notes.md @@ -1,2 +1,3 @@ * Removed methods deprecated in v1.9 (Issue #90, PR #92) -* Fixed behavior of `-extractFilesTo:overwrite:error:`, so it shows the progress of each individual file as they extract (Issue #91, PR #94) \ No newline at end of file +* Fixed behavior of `-extractFilesTo:overwrite:error:`, so it shows the progress of each individual file as they extract (Issue #91, PR #94) +* Deprecated the initializers that take a file path instead of an `NSURL` (Issue #90, PR #95) \ No newline at end of file