pixelglow / ZipZap

zip file I/O library for iOS, macOS and tvOS
BSD 2-Clause "Simplified" License
1.22k stars 199 forks source link

Error initializing the archive for in-memory use #145

Closed ilyakaz closed 8 years ago

ilyakaz commented 8 years ago

I can't find ZZMutableArchive in the current code. I tried initializing a ZZArchive instead in Swift based on sample code suggested in here, as follows:

let zipArchive = try ZZArchive.init(data: NSMutableData())

This code throws this error:

fatal error: 'try!' expression unexpectedly raised an error: Error Domain=com.pixelglow.ZipZap Code=0 "(null)" UserInfo={NSUnderlyingError=0x1546b0aa0 {Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."}}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-703.0.18.1/src/swift/stdlib/public/core/ErrorType.swift, line 54

pixelglow commented 8 years ago

You'll need to pass in the ZZOpenOptionsCreateIfMissingKey to enable writing

let zipArchive = try ZZArchive.init(data: NSMutableData(), options:[ZZOpenOptionsCreateIfMissingKey: true])

The API here is somewhat confusing, at some stage I'll go over it with a fine tooth comb and make it more usable.

ilyakaz commented 8 years ago

Great, this works! Thank you!