Purpose: Download the archived file, unzip it and save it in the document directory of the iPhone application.
The following code uses the initWithGzippedData method, which was added to NSData in the Molecule application, which is located here:
http://www.sunsetlakesoftware.com/molecules
According to my application:
NSString *sFolder = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *sFileName = [sFolder stringByAppendingPathComponent:@"MyFile.db"];
NSURL *oURL = [NSURL URLWithString: @"http://www.isystant.com/Files/MyFile.zip"];
NSData *oZipData = [NSData dataWithContentsOfURL: oURL];
NSData *oData = [[NSData alloc] initWithGzippedData:oZipData];
[oZipData release];
b = [oData writeToFile:sFileName atomically:NO];
NSLog(@"Unzip %i", b);
Result: zip file downloaded successfully. A new, supposedly unpacked file is created from it in the Documents directory with the desired name (MyFile.db), but it has zero bytes.
Does anyone see a problem? Or is there an easier way to unzip the downloaded file than the one used by Molecules?