To save an image data into an array in Swift, you can use the following code:
main.swift318 chars8 lines
This code first converts the UIImage
instance into Data
using the pngData()
method. Then, it initializes an empty array to store the image data. Finally, it checks if the image data is not nil
, and adds it to the array using the append()
method.
You can add as many images as you want to the array by calling this code for each image.
gistlibby LogSnag