首页 > 解决方案 > 将每个数组元素转换为单独的字符串

问题描述

假设,我有

var temp1TeamName = String()
var temp2TeamName = String()
var teamNameOnceArray = [[String]]()

我需要的

for i in 0..100 {
    if(i=0) {
        temp1TeamName = ((teamNameOnceArray[i] as AnyObject) as! String)
    }
    if(i=1) {
        temp2TeamName = ((teamNameOnceArray[i] as AnyObject) as! String)
    }
}

基本上我想将数组的每个元素存储到不同的字符串中。

但是在运行时它会崩溃。错误是

Could not cast value of type 'Swift._SwiftDeferredNSArray' (0x10560c988) to 'NSString' (0x1036ba2a8).

Could not cast value of type 'Swift._SwiftDeferredNSArray' (0x10560c988) to 'NSString' (0x1036ba2a8).

标签: iosswiftiphone

解决方案


推荐阅读