【发布时间】:2017-06-23 06:03:14
【问题描述】:
我想检查传出变量的值是 0 还是 1。我尝试下面的代码来做同样的事情,但我无法检查它。在下面的代码中,message 是一个包含 XMPPMessageArchiving_Message_CoreDataObject 值的字典。
如何查看outgoing变量的值?
message 字典包含:
bareJid = "(...not nil..)";
bareJidStr = "tester3@90.0.0.163";
body = "{\"Date\":\"14 Jun 2017\",\"Time\":\"4:21PM\",\"body\":\"hello\",\"filePath\":\"\",\"isImportant\":\"N\",\"isMine\":true,\"msgid\":\"167-36\",\"receiver\":\"tester1\",\"sender\":\"tester3\",\"senderName\":\"tester3\"}";
composing = 0;
message = "(...not nil..)";
messageStr = "<message xmlns=\"jabber:client\" to=\"tester1@90.0.0.163\" id=\"167-36\" type=\"chat\" from=\"tester3@90.0.0.163/Smack\"><body>{\"Date\":\"14 Jun 2017\",\"Time\":\"4:21PM\",\"body\":\"hello\",\"filePath\":\"\",\"isImportant\":\"N";
outgoing = 0;
streamBareJidStr = "tester1@90.0.0.163";
thread = "2066797c-4f79-48f3-bd04-30658ee35e9f";
timestamp = "2017-06-14 11:20:41 +0000";
当我调试outgoing 变量的值时,Xcode 显示它的类型是Any?,它的值是some。
let outgoing = messasge.value(forKey: "outgoing")
var isIncoming = true
if let og = outgoing as? Int {
if og == 1 {
isIncoming = false
}
}
【问题讨论】:
-
试着让出局 = messasge.value(forKey: "outgoing") as! Int,而不是 let
-
我试过了,但它会引发运行时错误。
-
Xcode 何时显示传出类型为 Any?它的价值是一些。传出是指针有意义吗?
-
@samdroid message["outgoing"] value data type is string or int??
-
@Subramanian 我无法理解传出变量的类型。我从 XMPPMessageArchiving_Message_CoreDataObject 检索数据。当我调试它时。它显示传出变量的类型 = Any?和价值 = 一些。
标签: ios swift xmppframework