我的问题是,此处“body.setStringValue(“Message”)“在swift 3.0中不可用,是否有用于传递消息的其他语法?

func xmppStreamDidAuthenticate(sender: XMPPStream!){

let body = DDXMLElement.elementWithName("body") as! DDXMLElement
let messageID = sender.generateUUID()

body.setStringValue("Message")

let completeMessage = DDXMLElement.elementWithName("message") as! DDXMLElement

completeMessage.addAttributeWithName("id", stringValue: messageID)
completeMessage.addAttributeWithName("type", stringValue: "chat")
completeMessage.addAttributeWithName("to", stringValue: "anotheruser@localhost")
completeMessage.addChild(body)

let active = DDXMLElement.elementWithName("active", stringValue:
  "http://jabber.org/protocol/chatstates") as! DDXMLElement
completeMessage.addChild(active)
sender.sendElement(completeMessage)}

最佳答案

let body = DDXMLElement(name: name, stringValue: stringValue)

关于ios - Swift 3.0中弃用了XMPP语法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40562143/

10-11 03:01