0

在 swift 2.2 中它的工作:

var messages = [JSQMessage]()

//...
for i in 1...10 {
 let sender = (i%2 == 0) ? "Server" : self.senderId
 let messageContent = "Message nr. \(i)"
 var message = JSQMessage(senderId: sender, displayName: sender, text: messageContent)
 self.messages += [message] //Cannot convert value of type '[JSQMessage]' to expected argument type 'inout_'
}

在 swift 3 中给我错误。试图使用

self.messages += [&message] // Type of expression is ambiguous without more context

怎么修?

4

1 回答 1

0

尝试这个: self.messages.append(message)

附加有很多变体:

https://stackoverflow.com/a/24002784/1979882

于 2016-10-22T16:56:46.853 回答