ObjectForKey方法未保存该值

时间:2017-08-25 03:59:20

标签: arrays swift nsdictionary

我正在尝试存储一些值来使用它们但是我正在编写这段代码并且在控制台中是打印的值但是当我尝试将该值分配给dateComp.day时它返回nil,而我不会知道为什么,你有没有想到为什么会发生这种情况提前感谢。

 for item in medicineArray {
            let obj = item as NSDictionary
            for (key, value) in obj {
                print("Property: \"\(key as! String)\"")


                dateComp.day = obj.object(forKey: ["day"]) as? Int
                dateComp.hour = obj.object(forKey: "time") as? Int
                print("componentes\(String(describing: dateComp.day))")
                print("componente2\(String(describing: dateComp.minute))")


            }

1 个答案:

答案 0 :(得分:0)

试试这个

    <form action="#">
    <input type="file" name="up_image_0" id="fileupload_0" onChange="ShowImageName('0')">
    <input type="file" name="up_image_1" id="fileupload_1" onChange="ShowImageName('1')">

    <input type="text" name="color_image_0" value="" id="img-holder_0">
    <input type="text" name="color_image_1" value="" id="img-holder_1">
    </form>

    <script>
     function ShowImageName(idx) {
      var new_name = $("#fileupload_"+idx).val();
      $("#img-holder_"+idx).text(new_name);
     } 
    </script>