# Swift 已有 array 转 NSMutableArray

**URL:** <https://www.shiqidu.com/t/topic/647>\
**Category:** 开发调优\
**Tags:** Swift\
**Created:** [September 22, 2019, 4:07pm UTC](https://www.shiqidu.com/t/topic/647 "2019-09-22T16:07:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
**Post date:** [September 22, 2019, 4:07pm UTC](https://www.shiqidu.com/t/topic/647/1 "2019-09-22T16:07:54Z")

</div>

Swift 将 现有的 array 转成 NSMutableArray 的方法

```swift
// array 转 NSMutableArray
func array2NSMutableArray(_ array: [Any]) -> NSMutableArray {
    let NSMutableArray: NSMutableArray = []
    for item in array {
        NSMutableArray.add(item)
    }
    return NSMutableArray
}

```
