Reputation: 16032
I wan to append objects from a NSMutablArray
to another NSMutableArray
on Swift 3 but I can't achieve that.
This is what I tried to do first:
mutableArray.addObjects(from: anotherMutableArray)
And I got this error:
Cannot convert value of type 'NSMutableArray?' to expected argument type '[Any]'
Then I tried this:
mutableArray.addObjects(from: anotherMutableArray as [Any])
And I got this error:
Cannot convert value of type 'NSMutableArray?' to type '[Any]' in coercion
How can I append objects from a NSMutableArray
to another NSMutableArray
on Swift 3?
Upvotes: 2
Views: 4469
Reputation: 318794
You need to cast the NSMutableArray
to a Swift array of AnyObject
, not Any
.
mutableArray.addObjects(from: anotherMutableArray as [AnyObject])
Upvotes: 5