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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -