Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 views
in Technique[技术] by (71.8m points)

swift2 - Swift 2 array of tuples not working as in swift 1

Array:

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

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)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...