Url.isFileReferenceURL () returns false for local file in IOS

I opened a PNG file in my application from another application.

It calls application(application: UIApplication, handleOpenURL url: NSURL) -> Boolthis function.

The following is what I did to verify the correctness of the following file:

func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool {
    var rootViewController : ViewController = self.window?.rootViewController as ViewController
    println("the received url is \(url) and \(url.isFileReferenceURL())")
    if url.isFileReferenceURL() {
        rootViewController.handleOpenURL(url)
        return true
    }

    return false
}

But when debugging url.isFileReferenceURL () returns false for a link to an example file, for example:

file:///private/var/mobile/Applications/56-random-identifier/Documents/Inbox/whatever.png

What's going on here? Why does the function return false for the local file? Thank!

+4
source share
1 answer

, -isFileReferenceURL. , , URL- URL- ; , , . -isFileURL , , fileURL (, url.fileURL).

URL- . URL- URL- . URL- , . , URL- . , URL- .

URL , . , URL- . , .

, -filePathURL -fileReferenceURL. -isFileReferenceURL.

URL- WithPath:, URL- . -isFileReferenceURL return false.

+18

All Articles