I tried this:
var ss: [S] = NSMutableArray<S>(capacity: 0)
Compiler says: Cannot specialize non-generic type 'NSMutableArray'
Why?
NSArray and NSMutableArray are Objective C types, and do not support generics. You can instantiate as swift's native array type:
var settings = [Setting]()
which also can be written as
var settings = Array<Setting>()
Thanks to type inference, you don't have to specify the type, but if you like this are the complete versions:
var settings: [Setting] = [Setting]()
var settings: Array<Setting> = Array<Setting>()
Note that [Setting] and Array<Setting> are interchangeable, meaning they define the same object type, so you can use whichever you like more.
NSOrderedSet to settings?NSOrderedSet has an array property of NSArray type. In order to take advantage of swift generics, you have to loop though that array, cast each element to Setting and add to the settings array+= array generic operator