交换数组元素显示错误:同时访问,但修改需要互斥访问 [英] Swap array elements show error: Simultaneous accesses to but modification requires exclusive access

查看:643
本文介绍了交换数组元素显示错误:同时访问,但修改需要互斥访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想交换数组元素:

swap(&(self.profileImages[0]), &(self.profileImages[2]))

但是我得到这个错误:

同时访问0x102944a80,但修改需要独占访问权限

Simultaneous accesses to 0x102944a80, but modification requires exclusive access

推荐答案

经过大量搜索:如

After lots of searching: As Whats-new-in-Swift-4 describe I found that in swift4 I should use this code:

self.profileImages.swapAt(0, 2)

这篇关于交换数组元素显示错误:同时访问,但修改需要互斥访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆