ios - Preserving Images In an IBOutletCollection -


here code far:

@iboutlet var boxes: [uiimageview]! @ibaction func success(_ sender: any) {     if "" == defaults.value(forkey: "frequency") as? string{         box in boxes{             if box.image == uiimage(named:"blank.png"){                 box.image = uiimage(named:"arm.png")                 break             }         }     }     else if "twice" == defaults.value(forkey: "frequency") as? string{         box in boxes{             if box.image == uiimage(named:"arm1.png"){                 box.image = uiimage(named:"arm.png")                 break             }             else if box.image == uiimage(named:"blank.png"){                 box.image = uiimage(named:"arm1.png")                 break             }         }         }  } 

the defaults.value(forkey: frequency) used determine how user wants change grid. how create userdefaults restore images in grid on app close? (double tap home , swipe up). userdefaults right way this? feel easier, way messier create individual outlet each uiimageview , saving state each 1 through giant tree of code. thank you!

if images stored in bundle (manually added , won't changed) can save names userdefaults instead of saving images. otherwise use database. there nice framework realm. try it. also, store images, better convert them data


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -