当前位置 : 主页 > 手机开发 > 其它 >

数组 – 交换数组元素显示错误:同时访问但修改需要独占访问

来源:互联网 收集:自由互联 发布时间:2021-06-12
我想交换我的数组元素: swap((self.profileImages[0]), (self.profileImages[2])) 但我得到这个错误: Simultaneous accesses to 0x102944a80, but modification requires exclusive access 经过大量搜索:正如 Whats-new-in-S
我想交换我的数组元素:

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

但我得到这个错误:

Simultaneous accesses to 0x102944a80, but modification requires exclusive access

经过大量搜索:正如 Whats-new-in-Swift-4描述的那样,我发现在swift4中我应该使用这段代码:

self.profileImages.swapAt(0, 2)
网友评论