So I've added the function
Code:
- (NSString *)dataFilePath
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:l_zipfile];
}
and then I've modified the zip creating function
Code:
-(IBAction)createZip:(id)sender
{
NSLog(@"Entering %s", __FUNCTION__);
NSString *filePath = [self dataFilePath];
ZipArchive *currentZip = [[ZipArchive alloc] init];
BOOL ret = [currentZip CreateZipFile2:filePath];
// OR
//BOOL ret = [zip CreateZipFile2:l_zipfile Password:@"your password"]; //
//if the Password is empty, will get the same effect as [zip CreateZipFile2:l_zipfile];
ret = [currentZip addFileToZip:@"happyJack.png" newname:@"jack.png"];
if( ![currentZip CloseZipFile2] )
{
NSLog(@"Zip Error");
}
[currentZip release];
}
So it works and the zip file magically appears in the Documents directory. However, when I click on it it says "the file is empty". What else am I doing wrong?
Thanks again!