We have a Push-To-Talk application, which also allow user's to share the PDF file documents.
On receiving a PDF file document, which has a space in its file name. On saving the document in the DB with space. When user is trying to access the PDF file, in order to rule out issues where there can be special character's in its file name, we are encoding the file name using stringByAddingPercentEncodingWithAllowedCharacters, and URLPathAllowedCharacterSet is the character set used which converts space character (" ") to %20.
Later, path of the same encoded file name is sent to fileURLWithPath:. When the encoded URL is passed to [NSFileManager fileExistsAtPath:] the file is not found in the since in DB, file is saved with a space, but in the URL %20 is been swapped in-place of space character.
Issue case: Here, on passing the same encoded URL path of the PDF file to [NSFileManager fileExistsAtPath:] is returning false;
Query: On passing the filename with spaces encoded with stringByAddingPercentEncodingWithAllowedCharacters to [NSFileManager fileExistsAtPath:], the path is not converted back to the decoded file name and returning false
We have used a work around on this case, by forming the URL of the PDF file without encoding and passing it to fileURLWithPath, issue is not seen here. We have a query here, i.e. will fileURLWithPath will be able to handle different special characters without encoding.
We have also raised a Feedback Ticket on same: https://feedbackassistant.apple.com/feedback/16049504