let array = [1, 2, 9, 3, 22]
UserDefaults.standard.set(array, forKey: "studentIDs")
//get id's array from user defaults
let studentIdsArray = UserDefaults.standard.array(forKey: "studentIDs")
There are plenty of questions/solutions, here is one:
how to save and read array of array in NSUserdefaults in swift?
But as another user said, please take a look at the official documentation: https://developer.apple.com/documentation/foundation/userdefaults
1
solved How to store array of values in NSUserDefaults in swift