views:

268

answers:

2

I attempt to get the path of the document directory on the iPhone SDK with the following code:

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

I'm in distribution and not debug configuration. In debug a valid path is returned. Also I'm using iPhone OS 3.0

Please help!

Joe

A: 

The best way to get the documents directory is to write a method like this:

/**
 Returns the path to the application's documents directory.
 */
- (NSString *)applicationDocumentsDirectory {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
    return basePath;
}
Matthew Bischoff
He's getting a valid path in debug mode, so he already knows how to get the path.
Nathan de Vries
A: 

I can't give you any specific advice, but this other SO question implies that it's happened to someone else, and that the issue was to do with provisioning. Your best bet would be to comment on the answer to that question and see if you can get a response, since it looks like he found a solution.

Nathan de Vries