字典数组中的循环元素(Cycling element in array of dictionary)
我有这个代码:
let jsonResults = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSArray for element in jsonResults { for (chiave,valore) in element { print("la chiave\(chiave) è uguale a \(valore)") } }
我这行有一个错误:
for (chiave,valore) in element {
类型元素Aka AnyObject不符合协议'序列类型'
jsonResults是一个数组
和
元素是一个字典
我可以将元素转换为字典吗?
数组与此类似:
[0] : 92 elements ▿ [0] : 2 elements - .0 : NOME - .1 : MARIO ▿ [1] : 2 elements - .0 : CAP_DOMICILIO - .1 : 000000 ▿ [2] : 2 elements - .0 : DATA_ULTIMO_AGG - .1 : 2015-09-22
I have this code:
let jsonResults = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSArray for element in jsonResults { for (chiave,valore) in element { print("la chiave\(chiave) è uguale a \(valore)") } }
I have an erro in this row:
for (chiave,valore) in element {
Type element Aka AnyObject does not conform to protocol 'Sequence Type'
jsonResults is an Array
and
element is an Dictionary
Can I cast element as a Dictionary?
Array is similar to this:
[0] : 92 elements ▿ [0] : 2 elements - .0 : NOME - .1 : MARIO ▿ [1] : 2 elements - .0 : CAP_DOMICILIO - .1 : 000000 ▿ [2] : 2 elements - .0 : DATA_ULTIMO_AGG - .1 : 2015-09-22
原文:https://stackoverflow.com/questions/33001418
最满意答案
你是如何联系的? 我们的Java插件遇到了类似的问题。 如果
dynamic_cast
与构造对象的DLL位于不同的DLL中,则必须在加载DLL时调用dlopen
时设置RTLD_GLOBAL
。 如果DLL被隐式加载,它是否被设置将取决于它如何为DLL触发加载设置(这意味着您可能无法控制它)。 最后,我们必须确保没有隐式加载.so
(通过让Java加载一个特殊的加载器DLL,它以依赖顺序显式加载所有内容)。请注意,这可能不是您的问题; 我只是猜测,因为我没有足够的信息。 但我们有完全相同的症状。
Ok, After a lot of trials this was the solution.
I needed to export the interface classes explicitly, using attribute((visibility("default"))) And to make sure there is an entry in the vtable, define and empty virtual destructor for this.
It seems on some linux machines, if I don't export It does not recognize the RTTI, and returns a NULL.
相关问答
更多-
ssh
tar -zcvf - /root/bugzilla > bugzilla.tar.gz 避免中间副本。 另请参阅这篇文章的几个变种: 远程Linux服务器到远程Linux服务器目录副本。 怎么样? ssh tar -zcvf - /root/bugzilla > bugzilla.tar.gz avoids an intermediary copy. See also this post for a couple of variants: Remote Linux ... -
检查机器是否为UP / ALIVE(Check if machine is UP/ALIVE)[2021-09-21]
考虑到PING本质上是为了完成您正在尝试做的事情(看看机器是否可用并且响应),我会说它已经非常优雅了。 为什么复杂的事情? Considering that PING is essentially designed to do exactly what you're trying to do (see if a machine is available and responding), I'd say it's already pretty elegant. Why complicate things? -
如何将文件从远程linux机器复制到JSP web目录(How to copy file from remote linux machine to JSP web directory)[2021-12-15]
您可以使用JSch来获得SSH协议的纯Java实现并复制您的文件。 使用JSch进行文件传输( scp命令)可能有点棘手,因此您可以添加securechannelfacade来正确传输文件 You can use JSch to have a pure Java implementation of the SSH protocol and copy your file. File transfer (scp command) with JSch can be a bit tricky, so you can ... -
我找到了一种方法来做我想做的事。 做我最初想要的事情要求我将文件从本地机器传输到远程机器,然后运行脚本并将其传回。 最终它是我的互联网连接速度的函数。 由于我的本地联系并不那么强大,我意识到我最初的想法是有缺陷的。 最后,我刚刚将数据上传到远程计算机并在那里运行脚本。 这是最快的解决方案 I found a way to do what I wanted. Doing what I initially wanted requires me to transfer the files from the loc ...
-
这会做 def copyToServer(hostname, username, password, destPath, localPath): transport = paramiko.Transport((hostname, 22)) sftp = paramiko.SFTPClient.from_transport(transport) try: sftp.put(localPath, destPath) sftp.close() transport.close() ...
-
如何在Perl中监控远程Linux机器并检索已安装的软件?(How to monitor remote Linux machines and retrieve installed software in Perl?)[2023-08-14]
检查这些: http://www.net-snmp.org/docs/mibs/host.html http://www.oidview.com/mibs/0/RFC1213-MIB.html 这将为您提供内存/磁盘使用情况: snmptable -v1 -c public localhost hrStorageTable snmptable -v1 -c public localhost .1.3.6.1.2.1.25.2.3 这将为您提供处理器利用率: snmptable -v1 -c public ... -
你可以随时使用: ps auwx | grep kibana 它会列出kibana进程 小心:它也会列出命令本身 You can always use : ps auwx | grep kibana it'll list the kibana process Care: it'll list also the command itself
-
使用lsof命令确认MySQL正在侦听所需的地址和端口。 一个快速命令是: # lsof -nP -i :3306 您应该看到类似于以下内容的行: mysqld 3225 mysql 11u IPv4 20260 0t0 TCP *:3306 (LISTEN) 上面输出中的'*:3306'表示MySQL绑定到端口3306上的所有接口。 获取MySQL进程的PID后的另一种方法是: # lsof -nP -p 3225 | grep LISTEN mysqld 3225 mysql ...
-
你是如何联系的? 我们的Java插件遇到了类似的问题。 如果dynamic_cast与构造对象的DLL位于不同的DLL中,则必须在加载DLL时调用dlopen时设置RTLD_GLOBAL 。 如果DLL被隐式加载,它是否被设置将取决于它如何为DLL触发加载设置(这意味着您可能无法控制它)。 最后,我们必须确保没有隐式加载.so (通过让Java加载一个特殊的加载器DLL,它以依赖顺序显式加载所有内容)。 请注意,这可能不是您的问题; 我只是猜测,因为我没有足够的信息。 但我们有完全相同的症状。 Ok, Af ...
-
从Linux机器到Windows机器的远程文件传输[关闭](Remote File Transfer from Linux Machine to Windows Machine [closed])[2022-03-12]
Filezilla或WinSCP将完成这项工作。 只需要在Linux机器上运行SSH服务器,在防火墙中启用SSH端口(默认为tcp / 22),并且您的Windows计算机必须能够访问Linux主机 - 您可以尝试ping您的Windows计算机要验证。 如果你想要别的东西,可以配置Samba或者可能是WebDAV(httpd.apache.org/docs/2.4/mod/mod_dav.html),它允许你在没有其他工具的情况下将Linux目录作为驱动器安装在Win ...