0

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.

Screenshot #1

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
  • `"The folder “Inbox” doesn’t exist"` that's the main error. Check that: https://stackoverflow.com/questions/5138822/create-folder-directory-in-objective-c-cocoa – Larme Jun 08 '17 at 16:25
  • @Larme But are the copied files normally put there after all? I don't need it, I just read an article where it was said that the files are put there –  Jun 08 '17 at 17:14
  • Apparently is not the case anymore, the file is located at the given url. – Axel Guilmin Jun 07 '18 at 13:54

0 Answers0