字符串插值错误

时间:2017-10-17 17:15:42

标签: arrays swift dictionary

我定义了一个变量:

let recipenameString = recipename as! String
let indexString = index as! String
let leftsideString = leftside as! String
let rightsideString = rightside as! String

然后,我迭代了NSDictionary,我得到了这些值:

var firstString = "\(recipenameString) \(indexString)"
let secondString = ["\(leftsideString)", "\(rightsideString)"]
photosArray[firstString : secondString]

现在,问题是:

Cannot subscript a value of type '[String : [String]]' with an index of type '(firstString: [String])' 

我得到这个编译器错误,无法弄清楚字符串插值有什么问题:

{{1}}

有什么想法吗? 谢谢。

1 个答案:

答案 0 :(得分:0)

你有一本字典,但把它当成一个数组: 试试这个:

localhost:4000

这应该这样做

这也有帮助: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html