From 37c2a639f2371ba18c6a016603fec1eeb0d39c45 Mon Sep 17 00:00:00 2001 From: shoby Date: Tue, 26 Jan 2016 15:28:33 +0900 Subject: [PATCH 1/7] Use instancetype instead of id --- SBYZipArchive/SBYZipArchive.h | 2 +- SBYZipArchive/SBYZipArchive.m | 2 +- SBYZipArchive/SBYZipEntry.h | 8 ++++---- SBYZipArchive/SBYZipEntry.m | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SBYZipArchive/SBYZipArchive.h b/SBYZipArchive/SBYZipArchive.h index 9463a96..a134244 100644 --- a/SBYZipArchive/SBYZipArchive.h +++ b/SBYZipArchive/SBYZipArchive.h @@ -15,7 +15,7 @@ @property (strong, nonatomic, readonly) NSURL *url; @property (readonly) NSArray *entries; -- (id)initWithContentsOfURL:(NSURL *)url error:(NSError *__autoreleasing *)error; +- (instancetype)initWithContentsOfURL:(NSURL *)url error:(NSError *__autoreleasing *)error; - (BOOL)loadEntriesWithError:(NSError *__autoreleasing *)error; diff --git a/SBYZipArchive/SBYZipArchive.m b/SBYZipArchive/SBYZipArchive.m index 0ddc23a..dce0f3f 100644 --- a/SBYZipArchive/SBYZipArchive.m +++ b/SBYZipArchive/SBYZipArchive.m @@ -33,7 +33,7 @@ @interface SBYZipArchive () @implementation SBYZipArchive -- (id)initWithContentsOfURL:(NSURL *)url error:(NSError *__autoreleasing *)error +- (instancetype)initWithContentsOfURL:(NSURL *)url error:(NSError *__autoreleasing *)error { self = [super init]; if (self) { diff --git a/SBYZipArchive/SBYZipEntry.h b/SBYZipArchive/SBYZipEntry.h index 01dc279..92e06b6 100644 --- a/SBYZipArchive/SBYZipEntry.h +++ b/SBYZipArchive/SBYZipEntry.h @@ -16,10 +16,10 @@ @property (assign, nonatomic, readonly) NSUInteger fileSize; @property (assign, nonatomic, readonly) NSUInteger offset; -- (id)initWithArchive:(SBYZipArchive *)archive - fileName:(NSString *)fileName - fileSize:(NSUInteger)fileSize - offset:(NSUInteger)offset; +- (instancetype)initWithArchive:(SBYZipArchive *)archive + fileName:(NSString *)fileName + fileSize:(NSUInteger)fileSize + offset:(NSUInteger)offset; // To unzip small file synchronously - (NSData *)dataWithError:(NSError *__autoreleasing *)error; diff --git a/SBYZipArchive/SBYZipEntry.m b/SBYZipArchive/SBYZipEntry.m index 0258cf7..107576a 100644 --- a/SBYZipArchive/SBYZipEntry.m +++ b/SBYZipArchive/SBYZipEntry.m @@ -18,7 +18,7 @@ @interface SBYZipEntry () @implementation SBYZipEntry -- (id)initWithArchive:(SBYZipArchive *)archive +- (instancetype)initWithArchive:(SBYZipArchive *)archive fileName:(NSString *)fileName fileSize:(NSUInteger)fileSize offset:(NSUInteger)offset From bf0ae7bc8b2caf9de79bae00f0e7b3afce862b4c Mon Sep 17 00:00:00 2001 From: shoby Date: Tue, 26 Jan 2016 15:31:34 +0900 Subject: [PATCH 2/7] Removed unnecessary property attributes --- SBYZipArchive/SBYZipArchive.h | 2 +- SBYZipArchive/SBYZipArchive.m | 16 ++++++++-------- SBYZipArchive/SBYZipEntry.h | 8 ++++---- SBYZipArchive/SBYZipEntry.m | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/SBYZipArchive/SBYZipArchive.h b/SBYZipArchive/SBYZipArchive.h index a134244..a731194 100644 --- a/SBYZipArchive/SBYZipArchive.h +++ b/SBYZipArchive/SBYZipArchive.h @@ -12,7 +12,7 @@ @protocol SBYZipArchiveDelegate; @interface SBYZipArchive : NSObject -@property (strong, nonatomic, readonly) NSURL *url; +@property (nonatomic, readonly) NSURL *url; @property (readonly) NSArray *entries; - (instancetype)initWithContentsOfURL:(NSURL *)url error:(NSError *__autoreleasing *)error; diff --git a/SBYZipArchive/SBYZipArchive.m b/SBYZipArchive/SBYZipArchive.m index dce0f3f..04f6075 100644 --- a/SBYZipArchive/SBYZipArchive.m +++ b/SBYZipArchive/SBYZipArchive.m @@ -14,17 +14,17 @@ static const NSUInteger SBYZipArchiveBufferSize = 4096; @interface SBYZipArchive () -@property (strong, nonatomic, readwrite) NSURL *url; -@property (assign, nonatomic) unzFile unzFile; -@property (strong, nonatomic) NSMutableArray *cachedEntries; +@property (nonatomic, readwrite) NSURL *url; +@property (nonatomic) unzFile unzFile; +@property (nonatomic) NSMutableArray *cachedEntries; -@property (strong, nonatomic) dispatch_semaphore_t semaphore; +@property (nonatomic) dispatch_semaphore_t semaphore; -@property (strong, nonatomic) NSOutputStream *outputStream; -@property (strong, nonatomic) NSURL *unzipDestinationURL; +@property (nonatomic) NSOutputStream *outputStream; +@property (nonatomic) NSURL *unzipDestinationURL; -@property (assign, nonatomic) NSUInteger bytesUnzipped; -@property (assign, nonatomic) NSUInteger totalBytes; +@property (nonatomic) NSUInteger bytesUnzipped; +@property (nonatomic) NSUInteger totalBytes; @property (copy, nonatomic) void (^successBlock)(NSURL *); @property (copy, nonatomic) void (^failureBlock)(NSError *); diff --git a/SBYZipArchive/SBYZipEntry.h b/SBYZipArchive/SBYZipEntry.h index 92e06b6..8c3187d 100644 --- a/SBYZipArchive/SBYZipEntry.h +++ b/SBYZipArchive/SBYZipEntry.h @@ -11,10 +11,10 @@ @class SBYZipArchive; @interface SBYZipEntry : NSObject -@property (weak, nonatomic, readonly) SBYZipArchive *archive; -@property (copy, nonatomic, readonly) NSString *fileName; -@property (assign, nonatomic, readonly) NSUInteger fileSize; -@property (assign, nonatomic, readonly) NSUInteger offset; +@property (weak, nonatomic, readonly) SBYZipArchive *archive; +@property (copy, nonatomic, readonly) NSString *fileName; +@property (nonatomic, readonly) NSUInteger fileSize; +@property (nonatomic, readonly) NSUInteger offset; - (instancetype)initWithArchive:(SBYZipArchive *)archive fileName:(NSString *)fileName diff --git a/SBYZipArchive/SBYZipEntry.m b/SBYZipArchive/SBYZipEntry.m index 107576a..eea8188 100644 --- a/SBYZipArchive/SBYZipEntry.m +++ b/SBYZipArchive/SBYZipEntry.m @@ -10,10 +10,10 @@ #import "SBYZipArchive.h" @interface SBYZipEntry () -@property (weak, nonatomic, readwrite) SBYZipArchive *archive; -@property (copy, nonatomic, readwrite) NSString *fileName; -@property (assign, nonatomic, readwrite) NSUInteger fileSize; -@property (assign, nonatomic, readwrite) NSUInteger offset; +@property (weak, nonatomic, readwrite) SBYZipArchive *archive; +@property (copy, nonatomic, readwrite) NSString *fileName; +@property (nonatomic, readwrite) NSUInteger fileSize; +@property (nonatomic, readwrite) NSUInteger offset; @end @implementation SBYZipEntry From e61009cb574e356056323ab8776b5a486aa27f72 Mon Sep 17 00:00:00 2001 From: shoby Date: Tue, 26 Jan 2016 15:41:47 +0900 Subject: [PATCH 3/7] Modified spaces --- SBYZipArchive/SBYZipEntry.h | 2 +- SBYZipArchive/SBYZipEntry.m | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SBYZipArchive/SBYZipEntry.h b/SBYZipArchive/SBYZipEntry.h index 8c3187d..bb8d315 100644 --- a/SBYZipArchive/SBYZipEntry.h +++ b/SBYZipArchive/SBYZipEntry.h @@ -12,7 +12,7 @@ @interface SBYZipEntry : NSObject @property (weak, nonatomic, readonly) SBYZipArchive *archive; -@property (copy, nonatomic, readonly) NSString *fileName; +@property (copy, nonatomic, readonly) NSString *fileName; @property (nonatomic, readonly) NSUInteger fileSize; @property (nonatomic, readonly) NSUInteger offset; diff --git a/SBYZipArchive/SBYZipEntry.m b/SBYZipArchive/SBYZipEntry.m index eea8188..3a17b05 100644 --- a/SBYZipArchive/SBYZipEntry.m +++ b/SBYZipArchive/SBYZipEntry.m @@ -25,10 +25,10 @@ - (instancetype)initWithArchive:(SBYZipArchive *)archive { self = [super init]; if (self) { - self.archive = archive; - self.fileName = fileName; - self.fileSize = fileSize; - self.offset = offset; + self.archive = archive; + self.fileName = fileName; + self.fileSize = fileSize; + self.offset = offset; } return self; } From f563156d868cd2a580c5e4686f1b9dd23e0aeb1e Mon Sep 17 00:00:00 2001 From: shoby Date: Tue, 26 Jan 2016 15:45:13 +0900 Subject: [PATCH 4/7] Addd generics --- SBYZipArchive/SBYZipArchive.h | 2 +- SBYZipArchive/SBYZipArchive.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SBYZipArchive/SBYZipArchive.h b/SBYZipArchive/SBYZipArchive.h index a731194..a095ea4 100644 --- a/SBYZipArchive/SBYZipArchive.h +++ b/SBYZipArchive/SBYZipArchive.h @@ -13,7 +13,7 @@ @interface SBYZipArchive : NSObject @property (nonatomic, readonly) NSURL *url; -@property (readonly) NSArray *entries; +@property (readonly) NSArray *entries; - (instancetype)initWithContentsOfURL:(NSURL *)url error:(NSError *__autoreleasing *)error; diff --git a/SBYZipArchive/SBYZipArchive.m b/SBYZipArchive/SBYZipArchive.m index 04f6075..ea025c2 100644 --- a/SBYZipArchive/SBYZipArchive.m +++ b/SBYZipArchive/SBYZipArchive.m @@ -16,7 +16,7 @@ @interface SBYZipArchive () @property (nonatomic, readwrite) NSURL *url; @property (nonatomic) unzFile unzFile; -@property (nonatomic) NSMutableArray *cachedEntries; +@property (nonatomic) NSMutableArray *cachedEntries; @property (nonatomic) dispatch_semaphore_t semaphore; From ddaceb4df08401eedbb1cf919d8526ded0236706 Mon Sep 17 00:00:00 2001 From: shoby Date: Tue, 26 Jan 2016 15:47:42 +0900 Subject: [PATCH 5/7] Added nullability --- SBYZipArchive/SBYZipArchive.h | 13 ++++++++----- SBYZipArchive/SBYZipArchive.m | 2 +- SBYZipArchive/SBYZipEntry.h | 10 +++++++--- SBYZipArchive/SBYZipEntry.m | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/SBYZipArchive/SBYZipArchive.h b/SBYZipArchive/SBYZipArchive.h index a095ea4..2df1335 100644 --- a/SBYZipArchive/SBYZipArchive.h +++ b/SBYZipArchive/SBYZipArchive.h @@ -11,6 +11,8 @@ @protocol SBYZipArchiveDelegate; +NS_ASSUME_NONNULL_BEGIN + @interface SBYZipArchive : NSObject @property (nonatomic, readonly) NSURL *url; @property (readonly) NSArray *entries; @@ -23,12 +25,11 @@ - (void)unzipEntry:(SBYZipEntry *)entry toURL:(NSURL *)url - success:(void (^)(NSURL *unzippedFileLocation))success - failure:(void (^)(NSError *error))failure - progress:(void (^)(NSUInteger bytesUnzipped, NSUInteger totalBytes))progress; + success:(nullable void (^)(NSURL *unzippedFileLocation))success + failure:(nullable void (^)(NSError *error))failure + progress:(nullable void (^)(NSUInteger bytesUnzipped, NSUInteger totalBytes))progress; @end - extern NSString* const SBYZipArchiveErrorDomain; typedef NS_ENUM(NSInteger, SBYZipArchiveError) @@ -36,4 +37,6 @@ typedef NS_ENUM(NSInteger, SBYZipArchiveError) SBYZipArchiveErrorCannotOpenFile = 1, SBYZipArchiveErrorCannotGetFileInfo = 2, SBYZipArchiveErrorCannotUnzipEntryFile = 3, -}; \ No newline at end of file +}; + +NS_ASSUME_NONNULL_END diff --git a/SBYZipArchive/SBYZipArchive.m b/SBYZipArchive/SBYZipArchive.m index ea025c2..d7c1693 100644 --- a/SBYZipArchive/SBYZipArchive.m +++ b/SBYZipArchive/SBYZipArchive.m @@ -133,7 +133,7 @@ - (BOOL)loadEntriesWithError:(NSError *__autoreleasing *)error return YES; } -- (void)unzipEntry:(SBYZipEntry *)entry toURL:(NSURL *)url success:(void (^)(NSURL *))success failure:(void (^)(NSError *))failure progress:(void (^)(NSUInteger, NSUInteger))progress +- (void)unzipEntry:(SBYZipEntry *)entry toURL:(NSURL *)url success:(nullable void (^)(NSURL *))success failure:(nullable void (^)(NSError *))failure progress:(nullable void (^)(NSUInteger, NSUInteger))progress { if (!entry) { return; diff --git a/SBYZipArchive/SBYZipEntry.h b/SBYZipArchive/SBYZipEntry.h index bb8d315..8e0af9a 100644 --- a/SBYZipArchive/SBYZipEntry.h +++ b/SBYZipArchive/SBYZipEntry.h @@ -10,6 +10,8 @@ @class SBYZipArchive; +NS_ASSUME_NONNULL_BEGIN + @interface SBYZipEntry : NSObject @property (weak, nonatomic, readonly) SBYZipArchive *archive; @property (copy, nonatomic, readonly) NSString *fileName; @@ -26,8 +28,10 @@ // To unzip large file asynchronously - (void)unzipToURL:(NSURL *)url - success:(void (^)(NSURL *unzippedFileLocation))success - failure:(void (^)(NSError *error))failure - progress:(void (^)(NSUInteger bytesUnzipped, NSUInteger totalBytes))progress; + success:(nullable void (^)(NSURL *unzippedFileLocation))success + failure:(nullable void (^)(NSError *error))failure + progress:(nullable void (^)(NSUInteger bytesUnzipped, NSUInteger totalBytes))progress; @end + +NS_ASSUME_NONNULL_END diff --git a/SBYZipArchive/SBYZipEntry.m b/SBYZipArchive/SBYZipEntry.m index 3a17b05..763a6b8 100644 --- a/SBYZipArchive/SBYZipEntry.m +++ b/SBYZipArchive/SBYZipEntry.m @@ -38,7 +38,7 @@ - (NSData *)dataWithError:(NSError *__autoreleasing *)error return [self.archive dataForEntry:self error:error]; } -- (void)unzipToURL:(NSURL *)url success:(void (^)(NSURL *))success failure:(void (^)(NSError *))failure progress:(void (^)(NSUInteger, NSUInteger))progress +- (void)unzipToURL:(NSURL *)url success:(nullable void (^)(NSURL *))success failure:(nullable void (^)(NSError *))failure progress:(nullable void (^)(NSUInteger, NSUInteger))progress { [self.archive unzipEntry:self toURL:url success:success failure:failure progress:progress]; } From d58b0d9935cc3dfe68320b349d06b28e61dccb4a Mon Sep 17 00:00:00 2001 From: shoby Date: Tue, 26 Jan 2016 15:56:21 +0900 Subject: [PATCH 6/7] Update travis settings --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7561b1a..48ae30c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: objective-c +osx_image: xcode7.2 script: - make clean test From 2d1d683072a3294684b3137f18e3b27946ed588e Mon Sep 17 00:00:00 2001 From: shoby Date: Tue, 26 Jan 2016 16:34:54 +0900 Subject: [PATCH 7/7] Update Makefile --- Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f941ddd..5cb2622 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ -PROJECT = DemoApp/DemoApp.xcodeproj -SCHEME = DemoApp -TEST_SDK = iphonesimulator -CONFIGURATION_DEBUG = Debug +PROJECT = 'DemoApp/DemoApp.xcodeproj' +SCHEME = 'DemoApp' +DESTINATION = 'platform=iOS Simulator,name=iPhone 6s' clean: xcodebuild \ @@ -12,6 +11,5 @@ test: xcodebuild \ -project $(PROJECT) \ -scheme $(SCHEME) \ - -sdk $(TEST_SDK) \ - -configuration $(CONFIGURATION_DEBUG) \ + -destination $(DESTINATION) \ build test