I want to be able to have my iOS app use SF symbols and store them in my Entity
attribute in my Core Data
model. I’m guessing I need to use the Binary Data
attribute type because SF symbols are displayed using an Image View
. I’m looking for a way to take an SF symbol from a SwiftUI View
and store it in the Core Data
Model. I also want to be able to retrieve that stored Entity
attribute from my Core Data
model and display it in any SwiftUI views I might choose.
How can I do this?
The actual visual data for each SFSymbol is provided by the operating system and is referenced by the symbol’s name. As such, you do not need to create a copy of that data and store it in your Core Data model. You can always get the same image data back from the system by specifying the same name you used to initially display the symbol in the image view.
So, you can just add a String property to your entity, such as symbolName, to reference the SF Symbol.