hemlocker
hemlocker

Reputation: 1052

Accessing NSDocumentDirectory on iPad Simulator

I've added a very simple .csv file to my app's NSDocumentDirectory using:

-(IBAction)exportModule:(id)sender{
    NSString *fileName = @"exportedfile.csv";
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];  
    NSString *exportString = @"I've,been,exported";
    NSData *testData=[exportString dataUsingEncoding:NSUTF8StringEncoding];
    NSString *docDir = documentsDirectory;
    NSString *completePath = [docDir stringByAppendingPathComponent:fileName];
    [testData writeToFile:completePath atomically:YES];

    if ([[NSFileManager defaultManager] fileExistsAtPath:completePath]) {
    NSLog(@"Theres a file here!");
    }

}

The app gets into the if statement printing "Theres a file here!", however I would like open the file and see if there were any problems in formatting the .csv.

If I were running on a physical device, I'd be able to open it up in iTunes and take a look there, but is there a way to examine the .csv while only using the simulator?

Upvotes: 2

Views: 1648

Answers (1)

Dan Rosenstark
Dan Rosenstark

Reputation: 69747

I have this at the beginning of all of my programs for using the simulator

NSLog(@"Documents: %@", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]);

Upvotes: 5

Related Questions