Swift Error: cannot convert of type '()' to specified type 'Bool'

前端 未结 2 1927
旧时难觅i
旧时难觅i 2021-01-23 15:24

I am New for Swift and I Have Implement File Manager Concept in my Project but it shows the issue and I don\'t for how to solve this please any body help me for fix the issue.

2条回答
  •  囚心锁ツ
    2021-01-23 16:06

    The method setResourceValue is a throw function and does not return a Bool.

    Try running your function using a do-catch:

    do {
        try URL.setResourceValue(Int(true), forKey: NSURLIsExcludedFromBackupKey)
    }
    catch {
        NSLog("Error excluding %@ from backup %@", URL.lastPathComponent!, err!)
    }
    

提交回复
热议问题