我希望数组的结构作为参数在我的函数中进行更改,如果我想要字符串来更改我把文本:字符串,但是当我想测试时要放什么:ArrayOfStruct作为参数?如何获取多个结构数组的一个函数?
func prizeCsGoArraySetup(arrayToAppend: here i want my struct){
if UserDefaults.standard.object(forKey: "prizeArray") != nil {
let demo = UserDefaults.standard.object(forKey: "prizeArray") as! NSDictionary
if let priArray = demo.value(forKey: "csgo") as? NSArray{
for prizeItem in priArray {
if let prizeVC = prizeItem as? NSDictionary{
let newElement : prize = prize(category: prizeVC.value(forKey: "category") as! String, name: prizeVC.value(forKey: "name") as! String, price: prizeVC.value(forKey: "price") as! Int, image: prizeVC.value(forKey: "image") as! String)
arrayToAppend.append(newElement)
我想为另外7个数组添加可变结构数组,怎么做? 我不想整个函数写7次。
很难说出你在问什么。你能否将你的代码减少到能够说明你的问题的MWE? – Raphael