gpt4 book ai didi

swift - 奇怪的数组错误-仅发生在设备上

转载 作者:行者123 更新时间:2023-11-30 13:23:04 24 4
gpt4 key购买 nike

使用模拟器,效果很好,结果符合预期,但在设备上,我在编译时遇到错误:

//data is array, where each element is array of strings
for array in data
{
let firstChar=array[0] //error here on device compilation only

错误:下标的使用不明确

编辑:

 data.removeAllObjects()
data=tdata.mutableCopy() as! NSMutableArray

//其中tdata为NSArray

最佳答案

我已经设法解决这个问题:

        var thisArray:NSMutableArray=[]
thisArray=array.mutableCopy() as! NSMutableArray
let firstChar=thisArray[0]

这样编译器就知道“thisArray”是一些可变数组。

关于swift - 奇怪的数组错误-仅发生在设备上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37548376/

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