Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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 条件绑定中的Swift绑定值必须为可选类型_Ios_Swift - Fatal编程技术网

Ios 条件绑定中的Swift绑定值必须为可选类型

Ios 条件绑定中的Swift绑定值必须为可选类型,ios,swift,Ios,Swift,错误: “条件绑定中的绑定值必须为可选类型” 我正在使用xcode 6.1.1,请帮忙。 我正在学习本教程,[您的意思是: if let ip = indexPath { var data: NSManagedObject = myList[ip.row] as NSManagedObject cell.textLabel?.text = data.valueForKeyPath("item") as String } 斯威

错误: “条件绑定中的绑定值必须为可选类型”

我正在使用xcode 6.1.1,请帮忙。

我正在学习本教程,[

您的意思是:

if let ip = indexPath {
            var data: NSManagedObject = myList[ip.row] as NSManagedObject
            cell.textLabel?.text = data.valueForKeyPath("item") as String

         }
斯威夫特说:“只需说
让ip=indepath
,或者直接使用
indepath
。if(或大括号)不需要
;这里不需要条件。”


原因可能是在您使用的教程设计时,
indepath
是可选的,需要取消包装。但现在它不是可选的。苹果会不时更改API。

如果您不了解可选的是什么,或者为什么需要取消包装,请参阅我的新教程:“If let”展开方式:但在本例中,您不需要知道这一点,因为
indepath
不是可选的。
if let ip = indexPath {