数组初始化调用Array.init(repeating: UIButton(), count: 6)
为啥数组中只有6个按钮,但是是同一个对象。不是应该创建六个不同的对象吗?
ios Swift 数组初始化
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- 云一程 2018-04-06 00:32关注
Declaration
iOS, macOS, tvOS, watchOS
init(repeating repeatedValue: Array.Element, count: Int)
Parameters
repeatedValue
The element to repeat.count
The number of times to repeat the value passed in the repeating parameter. count must be zero or greater.官方文档有提到,一个对象的重复
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报