0

I am very new to Swift. I have a mutable dictionary where I need to do a copy on it. I have the code in Objective-C and when I try to convert that to Swift it says Value of type [AnyHashable] has no member 'copy'. Can someone help me convert below ObjC code to Swift 4.

This is the original Objective-C code:

NSMutableArray *months = [[NSMutableArray alloc] init];

NSDictionary *monthDictionary = [[NSDictionary alloc] initWithObjects:@[[months copy]] forKeys:@[@"values"]];

Below is what I am trying when converting to Swift 4:

var months = [AnyHashable]()

var monthDictionary = [AnyHashable: Any](objects: [months.copy()], forKeys: ["values"])

Cannot use 'copy' here.

David Rönnqvist
  • 55,638
  • 18
  • 162
  • 201
AK1188
  • 17
  • 6

0 Answers0