Hi I have an app which uses its own document format (.hvgg). The UTI is declared in the Info.plist (screenshot). Did I do anything wrong there? Because when I use the "Share" menu, it shows "Copy to HvGG" instead of "Import to HvGG" which it says with all the other apps.
Anyways, my actual problem is that I can't find the file that is imported. I tried to find it using the document directory and adding "Inbox" but that didn't work. Is there a new path where the files are saved?
This is my code:
var opened: String?
var path: String?
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if String(describing: url)[0..<4] == "file" {
opened = "stundenplan"
let filemanager = FileManager.default
let paths: NSArray = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) as NSArray
let documentsDirectory: String = paths.object(at: 0) as! String
path = documentsDirectory.appending("/Inbox")
let dirFiles = try! filemanager.contentsOfDirectory(atPath: path!) <-- throws error
print (dirFiles)
}
return true
}
The error it returns:
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The folder “Inbox” doesn’t exist." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/9C0586AF-C0B8-440A-9151-13C6A061B3FB/Documents/Inbox, NSUserStringVariant=(
Folder), NSUnderlyingError=0x174050e90 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-802.0.31.3/src/swift/stdlib/public/core/ErrorType.swift, line 182