Thank you very much! I have managed to save the data with the help of your suggestion. I am adding the updated code as a comment for those who would come across the same question in the future.
Topic:
Programming Languages
SubTopic:
Swift
Tags: