Swift 2元组数组不像Swift 1中那样工作 [英] Swift 2 array of tuples not working as in swift 1

查看:69
本文介绍了Swift 2元组数组不像Swift 1中那样工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数组:

var rows: [(title: String, body: String, icon: String, iconColor: UIColor)] = []
rows.append(title: "Foo", body:"Bar", icon: "Bas", iconColor: UIColor(netHex: 0x4285f4))

自从我升级到Swift 2之后,附加行给了我以下错误:

the append line is giving me following error since I upgraded to swift 2:

Cannot invoke append with argument list of type (title: String, body: String, icon: String, iconColor: UIColor)

迅速1正常工作.知道怎么了吗?

in swift 1 it was working fine. Any idea whats wrong?

推荐答案

您要添加参数列表,而不是元组本身:您缺少一对().

You're appending the parameters list, not the tuple itself: you're missing a pair of ().

rows.append((title: "Foo", body:"Bar", icon: "Bas", iconColor: UIColor(netHex: 0x4285f4)))

这篇关于Swift 2元组数组不像Swift 1中那样工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆