gpt4 book ai didi

swift - 二元运算符 '-' 不能应用于两个 '[Float]' 操作数 - Surge.framework

转载 作者:行者123 更新时间:2023-11-30 13:43:52 25 4
gpt4 key购买 nike

我最近查看了 Surge 框架的新副本 here 。我成功地将其添加到我们的 Xcode 项目中,但收到以下编译错误。

二元运算符“-”不能应用于两个“[Float]”操作数

然后我尝试将其导入到一个全新的干净的 XCode 项目中,但仍然遇到相同的错误。有人以前见过这个错误并知道解决方法吗?或者是框架本身的问题。

最佳答案

你不能在数组上使用二元运算符,这就是你所拥有的。您可以看出,因为“Float”被括号括起来。您只能对单个值使用二元运算符。

var myArray = [Float]()  //An array(note the brackets)

myArray.append(15) //myArray now contains one value(15), but you still can't use binary operators on it because its an array.
print(myArray + myArray) //Error
print(myArray[0] + myArray[0]) //prints 30, using this syntax "myArray[0]" represents the first object in the array, 30 in this case.

长话短说,如果不需要数组,请切换到非数组 float ,或者直接访问数组中所需的项目,以便对它们使用二元运算符。

关于swift - 二元运算符 '-' 不能应用于两个 '[Float]' 操作数 - Surge.framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35214457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com