Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > ถามเรื่องโหลดข้อมูลจาก json เข้าใส่ PickerView [IOS Swift 5.1 Xcode 11.2]



 

ถามเรื่องโหลดข้อมูลจาก json เข้าใส่ PickerView [IOS Swift 5.1 Xcode 11.2]

 



Topic : 134626

Guest




ใครเขียน ios swift เข้ามาหน่อยค่ะต้องการคำแนะนำ โค้ดอาจจะยาวนิดนึงนะค่ะ ถ้าตัดบางส่วนกลัวไม่เข้าใจ
รบกวนถามเรื่อง
ถามเรื่องโหลดข้อมูลจาก json เข้าใส่ PickerView [IOS Swift 5.1 Xcode 11.2] คือ ต้องการให้ เมื่อเลือก Date Delivery แล้ว Shipment
จะเปลี่ยนตาม Date Delivery แต่ตอนนี้มีปัญหา มันไม่โหลด ลง picker view แต่ใน output panel มีค่าออกมา

ซ้ายคือต้นแบบ
ขวาคือกำลังจะทำโหลดจาก json

Code (PHP)
//
//  jsonGetShipmentViewController.swift
//  pickerDateAndShipment
//
//  Created by Nardanong.s on 22/11/2562 BE.
//  Copyright © 2562 TeamApp. All rights reserved.
//

import UIKit

class jsonGetShipmentViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate  {

//  ได้มาจากตอน login
var ptruckNoDCPlanData: String?
var ptruckidDCPlanData: String?
//    var ptruckidDCPlanData = "2"
var pplanimeiDCPlanData: String?

//รับค่ามาจาก getPlanDetail
var pshipment: String?
var pplandate: String?
var pPlandDetailIdDCPlanData: Int?

//  Picker view from database
var getpPlandateDCPlanData: [String] = []
var getpShipmentDCPlanData: [String] = []

var pplandateCategories : [String] = []
var secondColumnData = [[String]]()
    
@IBOutlet weak var getpPlanDatePickerView: UILabel!
@IBOutlet weak var someTextField: UILabel!
@IBOutlet weak var pickerview: UIPickerView!
@IBOutlet weak var getDriverNameLabel: UILabel!
@IBOutlet weak var getCarRegistrationLabel: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    getPlanDatetoPickerview(ptruckID: ptruckidDCPlanData!)
    secondColumnData = [getpShipmentDCPlanData]
    
    pickerview.delegate = self
    pickerview.dataSource = self
    
    pickerview.reloadAllComponents()
    pickerview.selectRow(0, inComponent: 0, animated: false)
    
//        print("pplandateCategories out func ==>\(pplandateCategories)")
//        print("secondColumnData out func ==>\(secondColumnData)")
}//Main Method

//  Get PlanDate
    func getPlanDatetoPickerview(ptruckID: String)-> Void {
//      Get value plan date from SQL/json
        let myconstant = Myconstant()
        let urlcheckPlanDate = myconstant.jsonGetPlanDate(pTruckID: ptruckID)
        print("//////////////-getPlanDate-/////////////////")
        print("urlcheckPlanDate ==> \(urlcheckPlanDate)")
        
        guard let url = URL(string: urlcheckPlanDate) else {
            return
        }//guard
        
        let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
            guard let dataResponsePlanDate = data, error == nil else{
                print("Have Error")
                return
            }//guard
            
            let resultDataResponsePlanDate: String = String(data: dataResponsePlanDate, encoding: .utf8)!
            print("resultDataResponse ==>",String(data:dataResponsePlanDate, encoding: .utf8)!)
            
            do{
//              Read json from API
                let strStringPlanDate = self.subStrString(result: resultDataResponsePlanDate)//For server value
                let strObjectPlanDate = Data(strStringPlanDate.utf8)
                print("strStringPlanDate ==> ",String(resultDataResponsePlanDate))
                print("strObjectPlanDate ==>",String(data:strObjectPlanDate, encoding: .utf8)!)
                
                let jsonResponsePlanDate = try JSONSerialization.jsonObject(with: strObjectPlanDate, options: []) as? [Dictionary<String,Any>]
                print("jsonResponsePlanDate ==> \(String(describing: jsonResponsePlanDate))")
                
//              Change json to array
                guard let jsonArrayPlanDate = jsonResponsePlanDate else{
                    return
                }//guard
                print("jsonArrayPlanDate ==>\(jsonArrayPlanDate)")
                
                var planDates:[String] = []
                if let jsonResponsePlanDate = jsonResponsePlanDate {
                    for dictionary in jsonResponsePlanDate {
                        planDates.append(dictionary["PlanDateFullFormat"]! as! String)
                        print("Loop planDates ==>",planDates)
                        self.pplandate = dictionary["PlanDateFullFormat"]! as? String
                    
                        DispatchQueue.main.async {
//                       Show on monitor =
                            self.getpPlandateDCPlanData = planDates
                            print("getpPlandateDCPlanData ==>\(self.getpPlandateDCPlanData)")
                            self.pplandateCategories = planDates
                            print("pplandateCategories ==>\(self.pplandateCategories)")
//                       Show on pickerView
                            self.getpPlanDatePickerView.text = dictionary["PlanDateFullFormat"]! as? String
//                                getpPlanDatePickerView.text = pplandateCategories
                            print("getpPlanDatePickerView ==>\(String(describing: self.getpPlanDatePickerView.text))")
                            
                            //self.getpPlanDatePickerView.text = self.convertToString(dateString: self.pplandate!, formatIn: "yyyyMMdd", formatOut: "MMM dd, yyyy")
                            //print("convertedFormat ==>\(String(describing: self.getpPlanDatePickerView.text))") // feb 12 2019
                         }//DispatchQueue
                    }//for
                }//if
                print("pplandate ==>\(String(describing: self.pplandate))")
                
//              //calling function
                self.getShipmenttoPickerView(shiptruckID: self.ptruckidDCPlanData!, shipplandate: self.pplandate!)
                
                //calling function
                //let convertedFormat =  self.convertToString(dateString: self.pplandate!, formatIn: "yyyyMMdd", formatOut: "MMM dd, yyyy")
                //print("convertedFormat ==>\(convertedFormat)") // feb 12 2019
                
            }catch let myerror{
                print(myerror)
//              Check display plandate in database
                print("No have truckID \(ptruckID) in database")
                DispatchQueue.main.async {
                    self.showAlert(title: "No have truckID", message: "No have truckID \(ptruckID) in database")
                }//DispatchQueue
            }//catch
        }//task
        task.resume()
    }//getPlanDatetoPickerview

//  Get Shipment
    func getShipmenttoPickerView(shiptruckID: String, shipplandate: String) -> Void {
//   Get value shipment from SQL/json
        let myconstant = Myconstant()
        let urlCheckShipment = myconstant.jsonGetShipment(pTruckId: shiptruckID, pPlanDate: shipplandate)
        print("//////////////-getShipment-/////////////////")
        print("urlCheckShipment ==> \(urlCheckShipment)")
        
        guard let urlShipment = URL(string: urlCheckShipment) else {
            return
        }//guartd
        
        let  task = URLSession.shared.dataTask(with: urlShipment) { (data, response, error) in
            guard let dataResponseshipment = data, error == nil else{
                print("Have Error")
                return
            }//guard
            
            let resultDataResponseShipment: String = String(data: dataResponseshipment, encoding: .utf8)!
            print("resultDataResponseShipment ==>", String(data: dataResponseshipment, encoding: .utf8)!)
            
        do{
//          Read json from API
            let strStringShipment = self.subStrString(result: resultDataResponseShipment) // For server value
            let strObjectShipment = Data(strStringShipment.utf8)
            print("strStringShipment ==>", String(resultDataResponseShipment))
            print("StrObjecxtShipment ==>", String(data:strObjectShipment, encoding: .utf8)!)
            
            let jsonResponseShipment = try JSONSerialization.jsonObject(with: strObjectShipment, options: []) as? [Dictionary<String,Any>]
            print("jsonResponseShipment ==> \(String(describing: jsonResponseShipment))")
            
//          Change json to array
            guard let jsonArrayshipment = jsonResponseShipment else{
                return
            }//guard
            print("jsonArrayshipment ==> \(jsonArrayshipment)")
            
            var planShipment:[String] = []
            if let jsonResponseShipment = jsonResponseShipment{
                for dictionary in jsonResponseShipment{
                    planShipment.append(dictionary["Shipment"]! as! String)
                    print("Loop planShipment ==> \(planShipment)")
                    self.pshipment = dictionary["Shipment"]! as? String
                    print("planShipment ==>\(planShipment)")
                    
                    DispatchQueue.main.async {
//                      Show on monitor
                        self.getpShipmentDCPlanData = planShipment
                        print("getpShipmentDCPlanData ==>\(self.getpShipmentDCPlanData)")
                        
                        self.secondColumnData = [planShipment]
                        print("secondColumnData ==>\(self.secondColumnData)")
//                      Show on pickerview
                        self.someTextField.text = dictionary["Shipment"]! as? String
                    }//DispatchQueue
                }//for
            }//if
            print("pshipment ==>\(String(describing: self.pshipment))")
            
//          Call func
            self.getPlanDetail(shipment: self.pshipment!, plandate: self.pplandate!)
            
            }catch let myerror{
                print(myerror)
//              Check display planshipment in database
                print("No have plan date \(String(describing: self.pplandate)) in database")
                DispatchQueue.main.async {
                    self.showAlert(title: "No have plan date", message: "No have plan date \(String(describing: self.pplandate)) in database")
                }//DispatchQueue
            }//catch
        }//task
        task.resume()
    }//getShipmenttoPickerView

//  Get Plan detail
    func  getPlanDetail(shipment: String, plandate: String)-> Void {
//      Get the value from database SQL Server
        print("//////////////-getPlanDetail-/////////////////")
        print("shipment=> \(shipment) plandate => \(plandate)")
        let myconstant = Myconstant()
        let urlGetPlanDetail = myconstant.jsonGetPlanDetail(pShipment: shipment, pPlanDate: plandate)
        
        guard let urlPlanDetail = URL(string: urlGetPlanDetail) else {
            return
        }//Guard
        print("urlGetPlanDetail ==> \(urlPlanDetail)")
        
        let task = URLSession.shared.dataTask(with: urlPlanDetail) { (data, response, error) in
            guard let dataResponsePlanDetail = data, error == nil else{
                print("Have Error")
                return
            }//guard
            
            let dataResultResponsePlanDetail: String = String(data: dataResponsePlanDetail, encoding: .utf8)!
            print("dataResultResponsePlanDetail ==>",String(data: dataResponsePlanDetail,encoding: .utf8)!)
            
            do{
//             Read json from  API
//              For server value
                let strStringPlanDetail: String = self.subStrString(result: dataResultResponsePlanDetail)
                let strObjectPlanDetail = Data(strStringPlanDetail.utf8)
                print("strStringPlanDetail ==>",String(strStringPlanDetail))
                print("strObjectPlanDetail ==>",String(data: strObjectPlanDetail,encoding: .utf8)!)
                
                let jsonResponsePlanDetail = try JSONSerialization.jsonObject(with: strObjectPlanDetail, options: []) as? [Dictionary<String,Any>]
                print("jsonResponsePlanDetail ==> \(String(describing: jsonResponsePlanDetail))")
                
//              Change json to array
                guard let jsonArrayPlanDetail = jsonResponsePlanDetail else{
                    return
                }//guard
                print("jsonArrayPlanDetail ==> \(String(describing: jsonArrayPlanDetail))")
                
//              Change array to dictionary
                guard let jsonDictionaryPlanDetail: Dictionary = jsonArrayPlanDetail.first  else{
                    return
                }//guard
                print("jsonDictionaryPlanDetail ==> \(String(describing: jsonDictionaryPlanDetail))")
                
//              Check data shipment for json Dictionary
                //PlanDetailID
                let PlanDetailID: Int = jsonDictionaryPlanDetail["PlanDetailID"] as! Int
                print("PlanDetailID ==>\(PlanDetailID)")
                
                self.pPlandDetailIdDCPlanData = Int(PlanDetailID)
                print("pPlandDetailId ==>\(String(describing: self.pPlandDetailIdDCPlanData))")
                
//              Driver
                let Driver1: String = jsonDictionaryPlanDetail["Driver1"] as! String
                let Driver2: String = jsonDictionaryPlanDetail["Driver2"] as! String
                print("Driver ==> \(String(describing: "Driver Name:" + Driver1 + "," + Driver2))")
                
//              Car registration get value from login
                let carRegistrtation: String = self.ptruckNoDCPlanData!
                print("carRegistrtation ==> \(String(describing: "Plate Number:" + carRegistrtation))")
                
//             Show data on monitor
                DispatchQueue.main.async {
                    self.getDriverNameLabel.text = "Driver Name: " + " " + Driver1 + "," + Driver2
                    self.getCarRegistrationLabel.text = "Plate Number:" + " " + carRegistrtation
                }//DispatchQueue
            }catch let myerror{
                print(myerror)
//              Check display data from database
                print("No have shipment \(String(describing: self.pplandate)) and \(String(describing: self.pshipment)) in database")
                DispatchQueue.main.async {
                    self.showAlert(title: "No data shipment", message: "No have  \(String(describing: self.pplandate)) and \(String(describing: self.pshipment)) in database")
                }//DispatchQueue
            }//ctach
        }//task
        task.resume()
    }//getPlanDetail


//Picker View function
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
      return 2
//        return secondColumnData.count
    }
    
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        if component == 0 {
            return pplandateCategories.count
        }else{
            let selected = pickerview.selectedRow(inComponent: 0)
            return secondColumnData[selected].count
        }
    }
    
    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        if component == 0 {
            return pplandateCategories[row]
        }else{
            let selected = pickerview.selectedRow(inComponent: 0)
            return secondColumnData[selected][row]
        }
    }
    
    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        if component == 0{
            pickerview.reloadComponent(1)
        }else{
            let selected = pickerview.selectedRow(inComponent: 0)
            someTextField.text = secondColumnData[selected][row]
        }
    }

//  SubStrString "\" from json
    func subStrString(result: String) -> String {
        let resultJson: String = result.replacingOccurrences(of: "\\\"", with: "\"")
        let resultJson1: String = "$" + resultJson + "$"
        let resultJson2: String = resultJson1.replacingOccurrences(of: "$\"", with: "")
        let resultJson3: String = resultJson2.replacingOccurrences(of: "\"$", with: "")
        return resultJson3
    }//subString

//  Ask save func
    func showAlert(title: String, message: String) -> Void {
        let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
            alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: {(action) in
                alert.dismiss(animated: true, completion: nil)
            }))//action
                self.present(alert,animated: true, completion: nil)
    }//showAlert
}


Output
Code (PHP)
/////////////-getPlanDate-/////////////////
urlcheckPlanDate ==> http://xxx.xxx.xxx.xxx/projectService/PODService.svc/GetPlanDate/2
resultDataResponse ==> "[  {    \"PlanDate\": \"27\/08\/2019\",    \"PlanDateFullFormat\": \"20190827\"  },  {    \"PlanDate\": \"28\/08\/2019\",    \"PlanDateFullFormat\": \"20190828\"  }]"
strStringPlanDate ==>  "[  {    \"PlanDate\": \"27\/08\/2019\",    \"PlanDateFullFormat\": \"20190827\"  },  {    \"PlanDate\": \"28\/08\/2019\",    \"PlanDateFullFormat\": \"20190828\"  }]"
strObjectPlanDate ==> [  {    "PlanDate": "27\/08\/2019",    "PlanDateFullFormat": "20190827"  },  {    "PlanDate": "28\/08\/2019",    "PlanDateFullFormat": "20190828"  }]
jsonResponsePlanDate ==> Optional([["PlanDate": 27/08/2019, "PlanDateFullFormat": 20190827], ["PlanDateFullFormat": 20190828, "PlanDate": 28/08/2019]])
jsonArrayPlanDate ==>[["PlanDate": 27/08/2019, "PlanDateFullFormat": 20190827], ["PlanDateFullFormat": 20190828, "PlanDate": 28/08/2019]]
Loop planDates ==> ["20190827"]
getpPlandateDCPlanData ==>["20190827"]
Loop planDates ==> ["20190827", "20190828"]
pplandateCategories ==>["20190827", "20190828"]
pplandate ==>Optional("20190828")
pplandateCategories out func ==>["20190827", "20190828"]
getpPlanDatePickerView ==>Optional("20190827")
secondColumnData out func ==>[[]]

//////////////-getShipment-/////////////////
urlCheckShipment ==> http://xxx.xxx.xxx.xx/projectService/PODService.svc/GetShipment/2/20190828
getpPlandateDCPlanData ==>["20190827", "20190828"]
pplandateCategories ==>["20190827", "20190828"]
getpPlanDatePickerView ==>Optional("20190828")
dataResponse ==> "[  {    \"Result\": \"Valid\",    \"TruckNo\": \"60-7624\",    \"TruckID\": \"2\"  }]"
strString ==> "[  {    \"Result\": \"Valid\",    \"TruckNo\": \"60-7624\",    \"TruckID\": \"2\"  }]"
strObject ==> [  {    "Result": "Valid",    "TruckNo": "60-7624",    "TruckID": "2"  }]
jsonResponse ==> Optional([["TruckID": 2, "TruckNo": 60-7624, "Result": Valid]])
jsonArray ==> [["TruckID": 2, "TruckNo": 60-7624, "Result": Valid]]
jsonDictionary ==>["TruckID": 2, "TruckNo": 60-7624, "Result": Valid]
checkResult ==>Valid
checkTruckID ==>2
truckid ==>Optional("2")
resultDataResponseShipment ==> "[  {    \"Shipment\": \"4505023244\"  },  {    \"Shipment\": \"4505023274\"  }]"
strStringShipment ==> "[  {    \"Shipment\": \"4505023244\"  },  {    \"Shipment\": \"4505023274\"  }]"
StrObjecxtShipment ==> [  {    "Shipment": "4505023244"  },  {    "Shipment": "4505023274"  }]
jsonResponseShipment ==> Optional([["Shipment": 4505023244], ["Shipment": 4505023274]])
jsonArrayshipment ==> [["Shipment": 4505023244], ["Shipment": 4505023274]]
Loop planShipment ==> ["4505023244"]
planShipment ==>["4505023244"]
Loop planShipment ==> ["4505023244", "4505023274"]
getpShipmentDCPlanData ==>["4505023244", "4505023274"]
planShipment ==>["4505023244", "4505023274"]
secondColumnData ==>[["4505023244", "4505023274"]]
pshipment ==>Optional("4505023274")

//////////////-getPlanDetail-/////////////////
shipment=> 4505023274 plandate => 20190828
urlGetPlanDetail ==> http://xxx.xxx.xxx.xx/projectService/PODService.svc/GetPlanDetail/4505023274/20190828
getpShipmentDCPlanData ==>["4505023244", "4505023274"]
secondColumnData ==>[["4505023244", "4505023274"]]
dataResultResponsePlanDetail ==> "[  {    \"DcName\": \"คลังบางนา\",    \"DcAppointmentDate\": \"2019-08-28T00:00:00\",    \"DcAppointmentTime\": \"00:30:00\",    \"DcCheckTime\": \"00:00:00\",    \"Driver1\": \"เรวัตร\",    \"Driver2\": \"ธงชัย\",    \"PersonCar1\": \"\",    \"PersonCar2\": \"\",    \"Shipment\": \"4505023274\",    \"InvioceQTY\": 1,    \"Dock\": \"\",    \"BoxQTY\": 2709,    \"Pallet\": 12,    \"StoreShortName\": \"ศ.ลำพูน\",    \"StoreAppointmentDate\": \"2019-08-27T00:00:00\",    \"StoreAppointmentTime\": \"27\/08\/2019 19:00\",    \"PlanHeadID\": 2,    \"PlanDetailID\": 2,    \"StoreID\": 4,    \"StoreCode\": \"THLPH0\",    \"Step\": 0,    \"DepartureCheck\": \"false\"  }]"
strStringPlanDetail ==> [  {    "DcName": "คลังบางนา",    "DcAppointmentDate": "2019-08-28T00:00:00",    "DcAppointmentTime": "00:30:00",    "DcCheckTime": "00:00:00",    "Driver1": "เรวัตร",    "Driver2": "ธงชัย",    "PersonCar1": "",    "PersonCar2": "",    "Shipment": "4505023274",    "InvioceQTY": 1,    "Dock": "",    "BoxQTY": 2709,    "Pallet": 12,    "StoreShortName": "ศ.ลำพูน",    "StoreAppointmentDate": "2019-08-27T00:00:00",    "StoreAppointmentTime": "27\/08\/2019 19:00",    "PlanHeadID": 2,    "PlanDetailID": 2,    "StoreID": 4,    "StoreCode": "THLPH0",    "Step": 0,    "DepartureCheck": "false"  }]
strObjectPlanDetail ==> [  {    "DcName": "คลังบางนา",    "DcAppointmentDate": "2019-08-28T00:00:00",    "DcAppointmentTime": "00:30:00",    "DcCheckTime": "00:00:00",    "Driver1": "เรวัตร",    "Driver2": "ธงชัย",    "PersonCar1": "",    "PersonCar2": "",    "Shipment": "4505023274",    "InvioceQTY": 1,    "Dock": "",    "BoxQTY": 2709,    "Pallet": 12,    "StoreShortName": "ศ.ลำพูน",    "StoreAppointmentDate": "2019-08-27T00:00:00",    "StoreAppointmentTime": "27\/08\/2019 19:00",    "PlanHeadID": 2,    "PlanDetailID": 2,    "StoreID": 4,    "StoreCode": "THLPH0",    "Step": 0,    "DepartureCheck": "false"  }]
jsonResponsePlanDetail ==> Optional([["PersonCar2": , "DepartureCheck": false, "PlanHeadID": 2, "Step": 0, "StoreShortName": ศ.ลำพูน, "DcName": คลังบางนา, "Driver1": เรวัตร, "StoreID": 4, "DcAppointmentDate": 2019-08-28T00:00:00, "InvioceQTY": 1, "StoreCode": THLPH0, "Dock": , "StoreAppointmentTime": 27/08/2019 19:00, "Pallet": 12, "BoxQTY": 2709, "StoreAppointmentDate": 2019-08-27T00:00:00, "DcCheckTime": 00:00:00, "PersonCar1": , "Shipment": 4505023274, "Driver2": ธงชัย, "PlanDetailID": 2, "DcAppointmentTime": 00:30:00]])
jsonArrayPlanDetail ==> [["PersonCar2": , "DepartureCheck": false, "PlanHeadID": 2, "Step": 0, "StoreShortName": ศ.ลำพูน, "DcName": คลังบางนา, "Driver1": เรวัตร, "StoreID": 4, "DcAppointmentDate": 2019-08-28T00:00:00, "InvioceQTY": 1, "StoreCode": THLPH0, "Dock": , "StoreAppointmentTime": 27/08/2019 19:00, "Pallet": 12, "BoxQTY": 2709, "StoreAppointmentDate": 2019-08-27T00:00:00, "DcCheckTime": 00:00:00, "PersonCar1": , "Shipment": 4505023274, "Driver2": ธงชัย, "PlanDetailID": 2, "DcAppointmentTime": 00:30:00]]
jsonDictionaryPlanDetail ==> ["PersonCar2": , "DepartureCheck": false, "PlanHeadID": 2, "Step": 0, "StoreShortName": ศ.ลำพูน, "DcName": คลังบางนา, "Driver1": เรวัตร, "StoreID": 4, "DcAppointmentDate": 2019-08-28T00:00:00, "InvioceQTY": 1, "StoreCode": THLPH0, "Dock": , "StoreAppointmentTime": 27/08/2019 19:00, "Pallet": 12, "BoxQTY": 2709, "StoreAppointmentDate": 2019-08-27T00:00:00, "DcCheckTime": 00:00:00, "PersonCar1": , "Shipment": 4505023274, "Driver2": ธงชัย, "PlanDetailID": 2, "DcAppointmentTime": 00:30:00]
PlanDetailID ==>2
pPlandDetailId ==>Optional(2)
Driver ==> Driver Name:เรวัตร,ธงชัย
carRegistrtation ==> Plate Number:60-7624

//////////////-getPlanDate-/////////////////
urlcheckPlanDate ==> http://xxx.xxx.xxx.xxx/projectService/PODService.svc/GetPlanDate/2
resultDataResponse ==> "[  {    \"PlanDate\": \"27\/08\/2019\",    \"PlanDateFullFormat\": \"20190827\"  },  {    \"PlanDate\": \"28\/08\/2019\",    \"PlanDateFullFormat\": \"20190828\"  }]"
strStringPlanDate ==>  "[  {    \"PlanDate\": \"27\/08\/2019\",    \"PlanDateFullFormat\": \"20190827\"  },  {    \"PlanDate\": \"28\/08\/2019\",    \"PlanDateFullFormat\": \"20190828\"  }]"
strObjectPlanDate ==> [  {    "PlanDate": "27\/08\/2019",    "PlanDateFullFormat": "20190827"  },  {    "PlanDate": "28\/08\/2019",    "PlanDateFullFormat": "20190828"  }]
jsonResponsePlanDate ==> Optional([["PlanDateFullFormat": 20190827, "PlanDate": 27/08/2019], ["PlanDateFullFormat": 20190828, "PlanDate": 28/08/2019]])
jsonArrayPlanDate ==>[["PlanDateFullFormat": 20190827, "PlanDate": 27/08/2019], ["PlanDateFullFormat": 20190828, "PlanDate": 28/08/2019]]
Loop planDates ==> ["20190827"]
Loop planDates ==> ["20190827", "20190828"]
getpPlandateDCPlanData ==>["20190827", "20190828"]
pplandate ==>Optional("20190828")
pplandateCategories ==>["20190827", "20190828"]
pplandateCategories out func ==>["20190827", "20190828"]
secondColumnData out func ==>[[]]

//////////////-getShipment-/////////////////
urlCheckShipment ==> http://xxx.xxx.xxx.xxx/projectService/PODService.svc/GetShipment/2/20190828
getpPlanDatePickerView ==>Optional("20190827")
getpPlandateDCPlanData ==>["20190827", "20190828"]
pplandateCategories ==>["20190827", "20190828"]
getpPlanDatePickerView ==>Optional("20190828")
resultDataResponseShipment ==> "[  {    \"Shipment\": \"4505023244\"  },  {    \"Shipment\": \"4505023274\"  }]"
strStringShipment ==> "[  {    \"Shipment\": \"4505023244\"  },  {    \"Shipment\": \"4505023274\"  }]"
StrObjecxtShipment ==> [  {    "Shipment": "4505023244"  },  {    "Shipment": "4505023274"  }]
jsonResponseShipment ==> Optional([["Shipment": 4505023244], ["Shipment": 4505023274]])
jsonArrayshipment ==> [["Shipment": 4505023244], ["Shipment": 4505023274]]
Loop planShipment ==> ["4505023244"]
planShipment ==>["4505023244"]
Loop planShipment ==> ["4505023244", "4505023274"]
planShipment ==>["4505023244", "4505023274"]
pshipment ==>Optional("4505023274")
getpShipmentDCPlanData ==>["4505023244", "4505023274"]

//////////////-getPlanDetail-/////////////////
shipment=> 4505023274 plandate => 20190828
secondColumnData ==>[["4505023244", "4505023274"]]
urlGetPlanDetail ==> http://xxx.xxx.xxx.xxx/projectService/PODService.svc/GetPlanDetail/4505023274/20190828
getpShipmentDCPlanData ==>["4505023244", "4505023274"]
secondColumnData ==>[["4505023244", "4505023274"]]
dataResultResponsePlanDetail ==> "[  {    \"DcName\": \"คลังบางนา\",    \"DcAppointmentDate\": \"2019-08-28T00:00:00\",    \"DcAppointmentTime\": \"00:30:00\",    \"DcCheckTime\": \"00:00:00\",    \"Driver1\": \"เรวัตร\",    \"Driver2\": \"ธงชัย\",    \"PersonCar1\": \"\",    \"PersonCar2\": \"\",    \"Shipment\": \"4505023274\",    \"InvioceQTY\": 1,    \"Dock\": \"\",    \"BoxQTY\": 2709,    \"Pallet\": 12,    \"StoreShortName\": \"ศ.ลำพูน\",    \"StoreAppointmentDate\": \"2019-08-27T00:00:00\",    \"StoreAppointmentTime\": \"27\/08\/2019 19:00\",    \"PlanHeadID\": 2,    \"PlanDetailID\": 2,    \"StoreID\": 4,    \"StoreCode\": \"THLPH0\",    \"Step\": 0,    \"DepartureCheck\": \"false\"  }]"
strStringPlanDetail ==> [  {    "DcName": "คลังบางนา",    "DcAppointmentDate": "2019-08-28T00:00:00",    "DcAppointmentTime": "00:30:00",    "DcCheckTime": "00:00:00",    "Driver1": "เรวัตร",    "Driver2": "ธงชัย",    "PersonCar1": "",    "PersonCar2": "",    "Shipment": "4505023274",    "InvioceQTY": 1,    "Dock": "",    "BoxQTY": 2709,    "Pallet": 12,    "StoreShortName": "ศ.ลำพูน",    "StoreAppointmentDate": "2019-08-27T00:00:00",    "StoreAppointmentTime": "27\/08\/2019 19:00",    "PlanHeadID": 2,    "PlanDetailID": 2,    "StoreID": 4,    "StoreCode": "THLPH0",    "Step": 0,    "DepartureCheck": "false"  }]
strObjectPlanDetail ==> [  {    "DcName": "คลังบางนา",    "DcAppointmentDate": "2019-08-28T00:00:00",    "DcAppointmentTime": "00:30:00",    "DcCheckTime": "00:00:00",    "Driver1": "เรวัตร",    "Driver2": "ธงชัย",    "PersonCar1": "",    "PersonCar2": "",    "Shipment": "4505023274",    "InvioceQTY": 1,    "Dock": "",    "BoxQTY": 2709,    "Pallet": 12,    "StoreShortName": "ศ.ลำพูน",    "StoreAppointmentDate": "2019-08-27T00:00:00",    "StoreAppointmentTime": "27\/08\/2019 19:00",    "PlanHeadID": 2,    "PlanDetailID": 2,    "StoreID": 4,    "StoreCode": "THLPH0",    "Step": 0,    "DepartureCheck": "false"  }]
jsonResponsePlanDetail ==> Optional([["PlanHeadID": 2, "StoreAppointmentDate": 2019-08-27T00:00:00, "Pallet": 12, "DcName": คลังบางนา, "DepartureCheck": false, "BoxQTY": 2709, "StoreID": 4, "PersonCar1": , "Step": 0, "StoreCode": THLPH0, "StoreShortName": ศ.ลำพูน, "DcCheckTime": 00:00:00, "Shipment": 4505023274, "StoreAppointmentTime": 27/08/2019 19:00, "PersonCar2": , "Dock": , "PlanDetailID": 2, "DcAppointmentTime": 00:30:00, "DcAppointmentDate": 2019-08-28T00:00:00, "InvioceQTY": 1, "Driver2": ธงชัย, "Driver1": เรวัตร]])
jsonArrayPlanDetail ==> [["PlanHeadID": 2, "StoreAppointmentDate": 2019-08-27T00:00:00, "Pallet": 12, "DcName": คลังบางนา, "DepartureCheck": false, "BoxQTY": 2709, "StoreID": 4, "PersonCar1": , "Step": 0, "StoreCode": THLPH0, "StoreShortName": ศ.ลำพูน, "DcCheckTime": 00:00:00, "Shipment": 4505023274, "StoreAppointmentTime": 27/08/2019 19:00, "PersonCar2": , "Dock": , "PlanDetailID": 2, "DcAppointmentTime": 00:30:00, "DcAppointmentDate": 2019-08-28T00:00:00, "InvioceQTY": 1, "Driver2": ธงชัย, "Driver1": เรวัตร]]
jsonDictionaryPlanDetail ==> ["PlanHeadID": 2, "StoreAppointmentDate": 2019-08-27T00:00:00, "Pallet": 12, "DcName": คลังบางนา, "DepartureCheck": false, "BoxQTY": 2709, "StoreID": 4, "PersonCar1": , "Step": 0, "StoreCode": THLPH0, "StoreShortName": ศ.ลำพูน, "DcCheckTime": 00:00:00, "Shipment": 4505023274, "StoreAppointmentTime": 27/08/2019 19:00, "PersonCar2": , "Dock": , "PlanDetailID": 2, "DcAppointmentTime": 00:30:00, "DcAppointmentDate": 2019-08-28T00:00:00, "InvioceQTY": 1, "Driver2": ธงชัย, "Driver1": เรวัตร]
PlanDetailID ==>2
pPlandDetailId ==>Optional(2)
Driver ==> Driver Name:เรวัตร,ธงชัย
carRegistrtation ==> Plate Number:60-7624


iOS



Tag : Mobile, Ms SQL Server 2016, iOS, iPhone, Swift, Web Services







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2019-12-11 16:01:06 By : nottpoo View : 51 Reply : 0
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ถามเรื่องโหลดข้อมูลจาก json เข้าใส่ PickerView [IOS Swift 5.1 Xcode 11.2]
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่