2013-10-29 3 views
2

인앱 구매시 사과 호스팅 콘텐츠가 .zip 파일로 다운로드됩니다. m이 내용의 압축을 풀려고했으나 zipArchive로 .zip 파일을 열어 제출했습니다.콘텐츠 압축 풀기 in-app 구매 ios

ZipArchive* za = [[ZipArchive alloc] init]; 
za.delegate = self; 
NSString *path = [download.contentURL path]; 
if([[NSFileManager defaultManager] fileExistsAtPath:path]) 
{ 
    NSLog(@"File Exists: %@", path); 
} 
else 
{ 
    NSLog(@"file not exists: %@", path); 
} 


if([za UnzipOpenFile:path]) { 
    if([za UnzipFileTo:dir overWrite:YES] != NO) 
    { 
     NSLog(@"unzip data success"); 
     //unzip data success 
     //do something 
    } 
    else 
    { 
     NSLog(@"unzip failed"); 
    } 


    [za UnzipCloseFile]; 
} 
else 
{ 
    NSLog(@"unzip can't open file"); 
} 

출력

파일이 존재한다 : ... 경로 .. 압축 해제 캔트 파일 열기

오히려 그 나는 자신의 .zip 파일을 묶을 경우 제대로 작동

path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"module.zip"]; 

ZipArchive* za = [[ZipArchive alloc] init]; 
za.delegate = self; 
if([[NSFileManager defaultManager] fileExistsAtPath:path]) 
{ 
    NSLog(@"File Exists: %@", path); 
} 
else 
{ 
    NSLog(@"file not exists: %@", path); 
} 


if([za UnzipOpenFile:path]) { 
    if([za UnzipFileTo:dir overWrite:YES] != NO) 
    { 
     NSLog(@"unzip data success"); 
     //unzip data success 
     //do something 
    } 
    else 
    { 
     NSLog(@"unzip failed"); 
    } 


    [za UnzipCloseFile]; 
} 
else 
{ 
    NSLog(@"unzip can't open file"); 
} 
여기

File Exists: /var/mobile/Applications/B22970ED-D30A-460A-A0A1-C8458795C370/myApp.app/module.zip 

myApp[615:907] 63 entries in the zip file 
2013-10-29 18:39:46.012 myApp[615:907] unzip data success 

답변

10

패키지의 압축을 풀지 마십시오. 이것은 단지 폴더입니다. 다음 코드를 사용하여 콘텐츠를 볼 수 있습니다.

NSArray *tempArrayForContentsOfDirectory =[[NSFileManager defaultManager] contentsOfDirectoryAtPath:[download.contentURL path] error:&error];