Re: initFileURLWithPath run on emulator, not run on device
Re: initFileURLWithPath run on emulator, not run on device
- Subject: Re: initFileURLWithPath run on emulator, not run on device
- From: David Duncan <email@hidden>
- Date: Mon, 30 Jan 2012 11:42:27 -0800
On Jan 30, 2012, at 10:50 AM, Stephen J. Butler wrote:
> On Mon, Jan 30, 2012 at 9:57 AM, Riccardo Barbetti
> <email@hidden> wrote:
>> I have a problem, after that I had write and test code on simulator, today I have work on device.
>
> I'm skeptical because...
>
>> In my program I save my NSArray:
>>
>>
>> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSSharedPublicDirectory, NSUserDomainMask, YES);
>>
>> NSString *documentsDirectory = [paths objectAtIndex:0];
>> NSURL *URLDirectory = [[NSURL alloc] initFileURLWithPath:documentsDirectory];
>>
>> BOOL result = [anArray writeToURL:URLDirectory atomically:YES];
>
> ... nowhere in this code do you add a filename to write to.
This is likely the root problem. The reason why it would work in the simulator but the device is likely due to permissions differences between the two. In the simulator you are typically allows to write practically anywhere in the simulated file system, since it is located inside of your home folder. On device you cannot write to the container directory of your application (which would be the permissions required to replace the 'Documents' folder).
As a rule, anything related to the hardware (such as the file system) is unlikely to be authoritative when working with the Simulator. The other common gotcha related to the file system is that typically your HD is formatted to be case insensitive, but iOS devices are formatted to be case sensitive.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden