views:

269

answers:

3

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.

A: 

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.

jamone
The app uses camera so the simulator will not do. (The phone locked up and the provider said that the sim supplied was not the latest and all phones needed the sim upgrade. She put the sim in and it didn't help so went into the back room. When I returned home my apps were gone, my notes and walla I had 4.0!). So it can happen without your permsission!
Matthew Weiss
Wow I'd demand the provider give me some large discounts. There is no call for them to loose all your data without even so much as a warning.
jamone
Well the young lady was trying to help, even though. Anyway, I would be here sooner or later with a voluntary upgrade and need to bite the bullet and get through 4.0.
Matthew Weiss
A: 

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.

Brad Larson
Thanks for that, I will have a look at the source but I am using that exact method to grab the directory and for some reason it refuses to write, without a error message in the logs.The other issue of the filesharing and seeing the files in Itunes... another mystery to be resolved. There was mention of adding a bundle of the filetype for sharing besides for the UIFileSharingEnabled, but I did doubt that is required and is the issue. Perhaps I should try that too.
Matthew Weiss
A: 

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

The problem of writing is solved for me with something trivial. I had not noticed that NSString *tempDir1 = NSTemporaryDirectory (); and the NSString *tempDir = [paths objectAtIndex:0]; return the directories one with a trailing "/" and one without.TempDirectory=/private/var/mobile/Applications/444D1E90-E302-4E7C-AE1E-3C007272C546/tmp/ homeDirectory=/var/mobile/Applications/444D1E90-E302-4E7C-AE1E-3C007272C546/Documents I still have an issue with getting the sharing working. The checkbox is checked and yet itunes will not pick it up. It sees FileApp just not my app.
Matthew Weiss