gpt4 book ai didi

ios - 为什么 NSDictionary 为零?

转载 作者:搜寻专家 更新时间:2023-10-31 08:20:25 25 4
gpt4 key购买 nike

这是我做错了帮助的代码。

         for result in (result2 ){

var dictData: NSDictionary?

dictData?.setValue(result.valueForKey("offer_title") as? String, forKey:"offer_title")
print(result.valueForKey("offer_title") as? String)
if result.valueForKey("discountPercentageOff") as? String != "" {
dictData?.setValue(result.valueForKey("discountPercentageOff") as? String, forKey:"discountPercentageOff")
print(result.valueForKey("discountPercentageOff") as? String)
}

dictData?.setValue(result.valueForKey("is_booked") as? Bool, forKey:"is_booked")
print(result.valueForKey("is_booked"))
dictData?.setValue(result.valueForKey("is_saved") as? Bool, forKey:"is_saved")
print(result.valueForKey("is_saved"))

dictData?.setValue(result.valueForKey("area_id") as? String, forKey:"area_id")
print(result.valueForKey("area_id"))

dictData?.setValue(result.valueForKey("area_name") as? String, forKey:"area_name")

dictData?.setValue(result.valueForKey("business_id") as? String, forKey:"business_id")
dictData?.setValue(result.valueForKey("business_name") as? String, forKey:"business_name")
dictData?.setValue(result.valueForKey("category_id") as? String, forKey:"category_id")
dictData?.setValue(result.valueForKey("category_name") as? String, forKey:"category_name")
dictData?.setValue(result.valueForKey("expiry_date") as? String, forKey:"expiry_date")
dictData?.setValue(result.valueForKey("featured") as? String, forKey:"featured")
dictData?.setValue(result.valueForKey("locality") as? String, forKey:"locality")
dictData?.setValue(result.valueForKey("offer_available") as? String, forKey:"offer_available")
dictData?.setValue(result.valueForKey("offer_id") as? String, forKey:"offer_id")
dictData?.setValue(result.valueForKey("offer_image") as? String, forKey:"offer_image")
dictData?.setValue(result.valueForKey("offer_nature") as? String, forKey:"offer_nature")
dictData?.setValue(result.valueForKey("offerNatureValue") as? String, forKey:"offerNatureValue")
dictData?.setValue(result.valueForKey("on_going") as? Bool, forKey:"on_going")
dictData?.setValue(result.valueForKey("discountOriginalPrice") as? String, forKey:"discountOriginalPrice")
dictData?.setValue(result.valueForKey("discountDiscountedPrice") as? String, forKey:"discountDiscountedPrice")

let offer = Offer()
offer.setDatafromServer(dictData!)
self.saveOfferData(item as! NSDictionary)
print("item:\(dictData)")

self._featuredOfferArray.addObject(offer)
self.feturedOfferTableView.reloadData()



}

当我将 nsdictionary 作为参数传递时,它给出错误可选 nil,你可以看到我在每个循环中创建了 nsdictionary。但它仍然是零。我无法理解。

最佳答案

 var dictData: NSDictionary?

将这一行改为

 var dictData = NSMutableDictionary();

关于ios - 为什么 NSDictionary 为零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37592595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com