pixelglow / ZipZap

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

Leave ZipZap archive safely #134

Closed ekuester closed 8 years ago

ekuester commented 8 years ago

Compiling of the ZipZap framework under OSX 10.11 succeeded. Using the framework I made a Swift project to display the contents of a zipped image archive. For that I use the following

    func actualEntryData() -> NSData? {
        let entry = imageArchive!.entries[entryIndex]
        do {
            let zipData = try entry.newData()
            window.title = (entry.fileName)
            return zipData
        } catch let error as NSError {
            Swift.print("Error: no valid data in \(error.domain)")
        }
        return nil
    }

Then the image is created easily

     if let imageObject = NSImage(data: data) {
         ...
    }

Works nice, but I wonder if the storage space of the old entrydatas is freed after choosing a new Zip file for displaying.

pixelglow commented 8 years ago

The storage space of old entry data should be freed when the last strong reference goes away. If you find that it doesn't, write up a minimal project that demonstrates it and I'll take a look.