-1

My project recently shows this error in Xcode:

'unarchiveTopLevelObjectWithData' was deprecated in macOS 10.14: Use unarchivedObject(ofClass:from:) instead

I found this article which speaks to my exact problem:

How to replace NSKeyedUnarchiver.unarchiveTopLevelObjectWithData with unarchivedObject when data is a Dictionary

Except that my data is an array of strings, not a dictionary. So, because I can't leave a comment on that post, I'm asking this as a new question.

How can I get the below solution to apply to [String]?

let dictionary = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSDictionary.self, NSArray.self], from: data) as? NSDictionary
atoss
  • 73
  • 5
  • Thank you, but I'd actually already tried that. It gives me this error: `'NSArray' is not convertible to '[String]'` – atoss Apr 14 '23 at 01:19

1 Answers1

0

The correct answer was:

let array = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSArray.self, NSString.self], from: data) as? [String]
atoss
  • 73
  • 5