-2

I need to mutate a NSDictionary in swift.

Hence I need to copy the elements of that NSDictionary to a swift Dictionary.

Something like the Objective-C equivalent of

[[NSMutableDictionary alloc] initWithDictionary:(nonnull NSDictionary *)];
7vikram7
  • 2,764
  • 1
  • 25
  • 43
  • You should simply stop using NSDictionary and NSMutableDictionary and just use a Swift dictionary with let (constant) or var (mutable). – Eric Aya Aug 26 '16 at 09:32

1 Answers1

2

A Dictionary is a struct in swift, which is a value type.

let firstDictionary = ....
let copyOfirstDictionary = firstDictionary// This will copy the contents from first dictionary to another.
pkc456
  • 8,350
  • 38
  • 53
  • 109