Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法转换类型为';inout NSNumber?&x27;到预期的参数类型';自动删除非可变指针<;任何对象?>';错误_Ios_Swift_Icloud_Nsurl - Fatal编程技术网

Ios 无法转换类型为';inout NSNumber?&x27;到预期的参数类型';自动删除非可变指针<;任何对象?>';错误

Ios 无法转换类型为';inout NSNumber?&x27;到预期的参数类型';自动删除非可变指针<;任何对象?>';错误,ios,swift,icloud,nsurl,Ios,Swift,Icloud,Nsurl,我使用此脚本检查从iCloud下载的*文件是否可用。但不幸的是,我遇到了错误无法将类型为“inout NSNumber?”的值转换为预期的参数类型“AutoReleasingUnsafemtablePointer” 看起来您复制并粘贴了一些非常旧的代码。此外,这是Swift,而不是Objective-C。不要使用NSURL或getResourceValue。您的代码应该更像这样: if let rv = try file?.resourceValues(forKeys: [.isUbiq

我使用此脚本检查从
iCloud
下载的*文件是否可用。但不幸的是,我遇到了错误
无法将类型为“inout NSNumber?”的值转换为预期的参数类型“AutoReleasingUnsafemtablePointer”


看起来您复制并粘贴了一些非常旧的代码。此外,这是Swift,而不是Objective-C。不要使用NSURL或
getResourceValue
。您的代码应该更像这样:

    if let rv = try file?.resourceValues(forKeys: [.isUbiquitousItemKey]) {
        if let isInCloud = rv.isUbiquitousItem {
            // and so on
        }
    }
    if let rv = try file?.resourceValues(
        forKeys: [.isUbiquitousItemKey, .ubiquitousItemDownloadingStatusKey]) {
            if let isInCloud = rv.isUbiquitousItem {
                if let status = rv.ubiquitousItemDownloadingStatus {
                    if status == .downloaded {

                    }
                }
            }
    }
等等;将相同的模式应用于其他关键点。请注意,也没有
.ubiquitousitemsdownloadkey
。你可以这样浓缩:

    if let rv = try file?.resourceValues(forKeys: [.isUbiquitousItemKey]) {
        if let isInCloud = rv.isUbiquitousItem {
            // and so on
        }
    }
    if let rv = try file?.resourceValues(
        forKeys: [.isUbiquitousItemKey, .ubiquitousItemDownloadingStatusKey]) {
            if let isInCloud = rv.isUbiquitousItem {
                if let status = rv.ubiquitousItemDownloadingStatus {
                    if status == .downloaded {

                    }
                }
            }
    }

实际上,我正在将objective c中的一个旧ios应用程序转换为swift。这个应用程序的一些功能对我来说是新的,这就是为什么我尝试使用一个网站来转换它。谢谢你的帮助。不要使用那种翻译网站。现在你知道为什么了!相反,要学会阅读Objective-C并写出Swift.:)是的,我会记下来的。我可以要求您提供您给我的答案的参考,以便我可以将其应用到我的代码中。谢谢,我不知道你说的推荐信是什么意思。事实就是事实。