kurtanamo
kurtanamo

Reputation: 1828

Zip NSData directly with SSZipArchive not working

I try to save nsdata as a zipped file like:

 let zipArch = SSZipArchive(path: "/var/mobile/Containers/Data/Application/5F3152AA-F07A-4AD2-98A9-22051C524AF2/Library/")
 print(zipArch.writeData(andCryptedData, filename: "aFileName.zip", withPassword: "aPass"))

writeData gives me always false - If I save the file first in this folder and zip it after this, it will work - but I don't want to save the file temporary anywhere - I need a solution to save a NSData directly to a zip.

Upvotes: 0

Views: 625

Answers (1)

kurtanamo
kurtanamo

Reputation: 1828

The right way to make nsdata directly to a zipped file is like that:

let zipArch = SSZipArchive(path: "path/to/library/directory/test.zip")
print(zipArch.open)
print(zipArch.writeData(aData!, filename: "aFileName.doc", withPassword: "aPass"))
print(zipArch.close)

print's just for checking if everything is created!

Upvotes: 2

Related Questions