swift3xcode8macos-sierrackasset

New "Non-file URL" Error In MacOS project Xcode8 Swift 3


I have some code that worked fine prior to upgrade to Swift 3 and xCode 8.0.

print("Thumb", self.theTempPath!)
video["videoThumbnail"] = CKAsset(fileURL: self.theTempPath! as URL)

produces this in the Console

Thumb /Users/prw/Documents/thumbTemp.jpg

2016-09-27 10:32:06.140 PA Places Data[2386:68875] Non-file URL

The print statement is for debugging only.

It appears to me that theTempPath! is a path to a file, so I am at a loss about how to address the issue. Execution does not halt, but nothing happens after CKAsset statement.

Can anyone explain what might be causing the issue?


Solution

  • You can use absoluteURL property of NSURL it will return URL object read Apple Documentation for more detail.

    if let url = self.theTempPath!.absoluteURL {    
        video["videoThumbnail"] = CKAsset(fileURL: url)
    }