1
votes

I was working prior to 4.0 OS with my iPhone and and writing to media/DCIM/100APPLE. I could download these files using DiskAid. This was a perfect dev solution. My provider without asking upgraded my phone to 4.0. Bang, I am no longer able to write anywhere visible. In distribution we will be using the temporary directory, no problem but in dev, I need to see the files are written correctly. I tried UIFileSharingEnabled

This has many problems and I understand it is only recognized in a deployed app, not in build and debug. If I don't delete the app before installing it does not let me write what I want to the document folder found by

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *tempDir = [paths objectAtIndex:0];

If I delete the app from the iphone and run it from xcode again for the first time, I get Error launching remote program: No such file or directory (/private/var/mobile/Applications/34846A80-429F-46CB-AC4B-09A701255839/myapp.app/myapp).

The only way around this, is to take out the filesharing from the info.plist run the debugger and the app runs normally, of course it still will not write to the above tempDir.

All works fine with NSString *tempDir = NSTemporaryDirectory (); but I can not see the file written and I am in the blind.

Has anyone found a solution to working in the dark.

3
Your provide updated you to iOS 4.0? How?ceejayoz

3 Answers

1
votes

You can indeed use iTunes file sharing for applications you are developing, not just for ones that have been deployed to the App Store. I'm not sure what's going wrong in your case, because the code you show:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

is what I use to grab the application's documents directory without a problem.

You can read and write to this directory freely, and its contents are updated in realtime while iTunes is connected to the device.

The source code to my application which uses file sharing is available, so you can take a look at it if that will help.

0
votes

I agree with @ceejayoz, you and iTunes updated your phone, the cell providors can't push updates. You had to accept it.

That aside, why can't you just run it in the simulator? Then all file writes to the app's temp directory will be on your computers HDD. The sim stores its filesystem in ~/Library/iPhone Simulator or something close to that.

0
votes

I have had a similar problem. I have been using the routine with NSArray *paths and the documentsDirectory to download files from a server and work with them in the phone. All was fine until 4.0 came out and now the app works in the simulator but will not run in the IPhone. The write stream will not open and I get this error:

Error Domain=NSPOSIXErrorDomain Code=1 "The operation couldn’t be completed. Operation not permitted" UserInfo=0x264d10 {} - error