In Swift 5, NSMutableArray has an initializer init(array:) which it inherits from NSArray . init(array:) has the following declaration:
convenience init(array anArray: NSArray)
Initializes a newly allocated array, placing the objects contained in this array into it.
The following Playground code example shows NSMutableArray create an NSMutableArray instance from an NSArray instance:
import Foundation let nsArray = [12, 14, 16] as NSArray var nsMutableArray = NSMutableArray(array: nsArray) print(nsMutableArray)
Imanou petit
source share