문제

I'm working on an iPad app and I'm using ZipArchive to unzip files that I download. However, when I try to open the files, I find that the open method thinks I passed in a nil parameter.

NSString* filepath = [[[NSBundle mainBundle] pathForResource:@"help_me.zip" ofType:@"zip"] copy];
ZipArchive* zipArchive = [[ZipArchive alloc] init];
[zipArchive UnzipOpenFile:filepath Password:@"XYZ"];

In the 'UnzipOpenFile' method, the debugger says that 'filePath' is nil. I'm not sure why this happens. Any ideas why?

도움이 되었습니까?

해결책

In

[[NSBundle mainBundle] pathForResource:@"help_me.zip" ofType:@"zip"]

you have specified the file extension twice, so that will return nil (unless your file is called "help_me.zip.zip"). It should be

[[NSBundle mainBundle] pathForResource:@"help_me" ofType:@"zip"]

Btw., there is no need to copy the file path.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top