将每个数组元素转换为单独的字符串

问题描述 投票:0回答:1

假设我有

`
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)
}

基本上我想将数组的每个元素存储到不同的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).

我不知道该怎么办。

我需要帮助!

请帮助我。

假设我有`var temp1TeamName = String()var temp2TeamName = String()var teamNameOnceArray = [[String]]()`我需要0..100 {if(i = 0){ temp1TeamName =(((...

ios swift iphone
1个回答
0
投票

我想您正在尝试将[String]转换为String。首先检查数据类型。

© www.soinside.com 2019 - 2024. All rights reserved.