Re: Unicode filenames with Apple File System and UIManagedDocument
Re: Unicode filenames with Apple File System and UIManagedDocument
- Subject: Re: Unicode filenames with Apple File System and UIManagedDocument
- From: email@hidden
- Date: Tue, 07 Mar 2017 11:13:40 -0500
> On Mar 7, 2017, at 9:55 AM, email@hidden wrote:
>
>
>> On Mar 7, 2017, at 7:47 AM, Jean-Daniel <email@hidden> wrote:
>>
>>
>>> Le 6 mars 2017 à 14:28, email@hidden a écrit :
>>>
>>> I have an iOS app (Attendance2) written in Objective-C. One of my users upgraded to the public 10.3 iOS beta and reported he could no longer open his documents (I have a subclass of UIManagedDocument so they are Core Data files stored in the package/directory format that UIManagedDocument uses). I didn’t notice any issues with my test device using the developer beta of 10.3. He changed the file names from Arabic to Roman and then he said he could open them.
>>>
>>> Everything I do with NSString is via UTF8 (and it worked fine with Arabic letters for this person before updating to the 10.3 beta) so I don’t think I’m doing anything wrong.
>>>
>>
>> Did you try to use NSString -fileSystemRepresentation instead of UTF-8, or even better, use URL. While using UTF-8 for path worked well on HFS+, It was never guaranteed to work on all FS.
>>
>
> I’ll take a look at this today. I suspect I’m not using fileSystemRepresentation. I’ll have to see when that is appropriate to use as I believe I’m creating a URL from the string the user types in and then using that as part of the URL for the UIManagedDocument.
>
> The person did create a new Arabic file under 10.3 and it opens fine, but the ones that we created under 10.2 won’t open under 10.3 unless the person changes the name so it uses Roman/English characters.
>
> If using fileSystemRepresentation doesn’t fix it, I’ll file a bug.
>
> Thanks,
> Dave Reed
Is this the correct way to do it (assuming the variable name is the NSString with the name of the file (and [self courseDirectory] is the directory the file is in?
NSFileManager *fm = [[NSFileManager alloc] init];
const char *data = [name fileSystemRepresentation];
NSString *filename = [fm stringWithFileSystemRepresentation:data length:strlen(data)];
NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:filename];
Before what I was doing is:
NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:name];
With the above changes, I can still open my files so it doesn't appear to break anything. I'll have to wait until I get home to see if that now lets me open the pre-created Arabic files (the person sent me a sample file that won't open in 10.3 and I can confirm it opens in 10.2 but not with my 10.3 test device) as I don't have Xcode 8.3 beta on my laptop and that seems to be required to load the data onto the 10.3 beta device.
Thanks,
Dave Reed
_______________________________________________
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