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 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 diff --git a/SBYZipArchive/SBYZipArchive.h b/SBYZipArchive/SBYZipArchive.h index 9463a96..2df1335 100644 --- a/SBYZipArchive/SBYZipArchive.h +++ b/SBYZipArchive/SBYZipArchive.h @@ -11,11 +11,13 @@ @protocol SBYZipArchiveDelegate; +NS_ASSUME_NONNULL_BEGIN + @interface SBYZipArchive : NSObject -@property (strong, nonatomic, readonly) NSURL *url; -@property (readonly) NSArray *entries; +@property (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; @@ -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 0ddc23a..d7c1693 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 *); @@ -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) { @@ -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 01dc279..8e0af9a 100644 --- a/SBYZipArchive/SBYZipEntry.h +++ b/SBYZipArchive/SBYZipEntry.h @@ -10,24 +10,28 @@ @class SBYZipArchive; +NS_ASSUME_NONNULL_BEGIN + @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; -- (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; // 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 0258cf7..763a6b8 100644 --- a/SBYZipArchive/SBYZipEntry.m +++ b/SBYZipArchive/SBYZipEntry.m @@ -10,25 +10,25 @@ #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 -- (id)initWithArchive:(SBYZipArchive *)archive +- (instancetype)initWithArchive:(SBYZipArchive *)archive fileName:(NSString *)fileName fileSize:(NSUInteger)fileSize offset:(NSUInteger)offset { 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; } @@ -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]; }