Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7021563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:28:01+00:00 2026-05-27T23:28:01+00:00

In my app, when a user makes an in app purchase, the application needs

  • 0

In my app, when a user makes an in app purchase, the application needs to download and unzip a zip file to the app’s documents folder. The zip file downloads and can be unzipped. I’m using Objective Zip to unzip the archive. The problem is that when trying to create the folder paths for each file, the folders are never created, and there is no error.

Here is some sample code for the section where this is happening:

// Create file manager
NSFileManager *fileMgr = [NSFileManager defaultManager];

//Unzip
NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
ZipFile *unzipFile = [[ZipFile alloc] initWithFileName:[applicationDocumentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",@"Mid America Oireachtas 2011"]] mode:ZipFileModeUnzip];
NSArray *infos= [unzipFile listFileInZipInfos];
for (FileInZipInfo *info in infos) {
    //NSLog(@"- %@ %@ %d (%d)", info.name, info.date, info.size, info.level);

    // Locate the file in the zip
    [unzipFile locateFileInZip:info.name];

    // Expand the file in memory
    ZipReadStream *read= [unzipFile readCurrentFileInZip];
    NSMutableData *data= [[NSMutableData alloc] initWithLength:info.length];
    int bytesRead = [read readDataWithBuffer:data];
    [read finishedReading];
    NSString *appSupportFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString *pathfull = [appSupportFolder stringByAppendingPathComponent:info.name];
    NSString *path = [[pathfull stringByDeletingLastPathComponent] copy];
    NSError *errorw;
    NSRange range = [path rangeOfString:@"__MACOSX"];
    if (range.location == NSNotFound) {
        NSLog(@"last: %@", [path lastPathComponent]);
        if ([fileMgr createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&errorw]) {
            NSLog(@"Create Folder: %@", path);
            NSLog(@"Directory Win: %@", errorw);
            if (![[pathfull pathExtension] isEqualToString:@""] && ![[[pathfull lastPathComponent] substringToIndex:1] isEqualToString:@"." ]) {
                [data writeToFile:pathfull atomically:NO];
            }
        }
        else {
            //NSLog(@"Create Folder: %@", path);
            NSLog(@"Directroy Fail: %@", errorw);
        }
    }
}

[unzipFile close];

//delete zip
// For error information
NSError *error;

if ([fileMgr removeItemAtPath:[applicationDocumentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",@"Mid America Oireachtas 2011"]] error:&error] == YES) {
    NSLog(@"File Deleted");
}

//delete zip
// For error information
NSError *error;

if ([fileMgr removeItemAtPath:[applicationDocumentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",@"My Zip"]] error:&error] == YES) {
    NSLog(@"File Deleted");
}

Here is relevant snippet of output from the log file:

    2012-01-04 17:12:51.509 WhatsMyStageOn[3232:15503] Create Folder: /Users/Brandon/Library/Application Support/iPhone Simulator/5.0/Applications/436C2C49-D79B-4CDA-B0AA-15BB98F6F75E/WhatsMyStageOn.app/
    2012-01-04 17:12:51.510 WhatsMyStageOn[3232:15503] Directory Win: (null)
    2012-01-04 17:12:51.510 WhatsMyStageOn[3232:15503] Create Folder: /Users/Brandon/Library/Application Support/iPhone Simulator/5.0/Applications/436C2C49-D79B-4CDA-B0AA-15BB98F6F75E/WhatsMyStageOn.app/Documents/Mid America Oireachtas 2011
    2012-01-04 17:12:51.510 WhatsMyStageOn[3232:15503] Directory Win: (null)
    2012-01-04 17:12:51.510 WhatsMyStageOn[3232:15503] Create Folder: /Users/Brandon/Library/Application Support/iPhone Simulator/5.0/Applications/436C2C49-D79B-4CDA-B0AA-15BB98F6F75E/WhatsMyStageOn.app/Documents
    2012-01-04 17:12:51.510 WhatsMyStageOn[3232:15503] Directory Win: (null)
    2012-01-04 17:12:51.511 WhatsMyStageOn[3232:15503] Create Folder: /Users/Brandon/Library/Application Support/iPhone Simulator/5.0/Applications/436C2C49-D79B-4CDA-B0AA-15BB98F6F75E/WhatsMyStageOn.app/Documents/__MACOSX
    2012-01-04 17:12:51.511 WhatsMyStageOn[3232:15503] Directory Win: (null)
    2012-01-04 17:12:51.511 WhatsMyStageOn[3232:15503] Create Folder: /Users/Brandon/Library/Application Support/iPhone Simulator/5.0/Applications/436C2C49-D79B-4CDA-B0AA-15BB98F6F75E/WhatsMyStageOn.app/Documents/__MACOSX/Mid America Oireachtas 2011
    2012-01-04 17:12:51.511 WhatsMyStageOn[3232:15503] Directory Win: (null)
    2012-01-04 17:12:51.511 WhatsMyStageOn[3232:15503] Create Folder: /Users/Brandon/Library/Application Support/iPhone Simulator/5.0/Applications/436C2C49-D79B-4CDA-B0AA-15BB98F6F75E/WhatsMyStageOn.app/Documents/Mid America Oireachtas 2011
    2012-01-04 17:12:51.512 WhatsMyStageOn[3232:15503] Directory Win: (null)
    2012-01-04 17:12:51.544 WhatsMyStageOn[3232:15503] Create Folder: /Users/Brandon/Library/Application Support/iPhone Simulator/5.0/Applications/436C2C49-D79B-4CDA-B0AA-15BB98F6F75E/WhatsMyStageOn.app/Documents/Mid America Oireachtas 2011/Attractions
    2012-01-04 17:12:51.544 WhatsMyStageOn[3232:15503] Directory Win: (null)

Reading the NSFileManager documentation, this is what should output in the log, but, No folders are created.

EDIT: Fixed not using documents issue, still have same problem as decried before edit.

EDIT: Updated code to working solution!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:28:02+00:00Added an answer on May 27, 2026 at 11:28 pm

    You shouldn’t be writing to the app’s bundle itself. Try this:

    NSString *appSupportFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString *path = [appSupportFolder stringByAppendingPathComponent:info.name];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any functionality in Google's in-app purchase API that can charge a user's
I am developing an application in which user can purchase any image he likes.
I have an application using in-app purchase. Apparently, if the user has a jailbroken
I have a small app, where user can make some calculations and solve equations.
I'm developing web app that user can save his/her work to server. The data
Just as on StackOverflow, in my app a User can write Questions and can
i developed a application with in app purchases..when user buys the subscription it gets
I have an app that makes user of filtering certain things for users with
I have an app that allows users to purchase publications that download to their
I'm doing an android application much like the gmail app for android. I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.