Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 我想打印对myTableViewController的soap响应_Ios_Swift_Web Services_Soap - Fatal编程技术网

Ios 我想打印对myTableViewController的soap响应

Ios 我想打印对myTableViewController的soap响应,ios,swift,web-services,soap,Ios,Swift,Web Services,Soap,您好,我是Swift和SOAP新手,我正在使用并获得回复,回复为posts我想将此response打印到myTableViewController请帮助谢谢 响应 {Country = ""GetCitiesByCountryResult = "<NEWDATASET><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>BHAIRAWA AIRPORT</CITY></TABLE><T

您好,我是Swift和SOAP新手,我正在使用并获得回复,回复为
posts
我想将此
response
打印到
myTableViewController
请帮助谢谢
响应

{Country = ""GetCitiesByCountryResult = "<NEWDATASET><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>BHAIRAWA AIRPORT</CITY></TABLE><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>JUMLA</CITY></TABLE><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>KATHMANDU AIRPORT</CITY></TABLE><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>POKHARA AIRPORT</CITY></TABLE><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>SIMRA AIRPORT</CITY></TABLE><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>SURKHET</CITY></TABLE><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>TAPLEJUNG</CITY></TABLE><TABLE><COUNTRY>NEPAL</COUNTRY><CITY>BIRATNAGAR AIRPORT</CITY></TABLE></NEWDATASET>";}    
class myTableViewController: UIViewController , UITableViewDataSource , UITableViewDelegate {

@IBOutlet weak var tableView: UITableView!

var city = NSMutableArray()

override func viewDidLoad() {
    super.viewDidLoad()

        tableView.delegate = self
        tableView.dataSource = self
    tableView!.reloadData()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func tableView(_ tableView:UITableView, numberOfRowsInSection section:Int) -> Int
{
    return city.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    var cell : UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
    if(cell.isEqual(NSNull.self)) {
        cell = Bundle.main.loadNibNamed("Cell", owner: self, options: nil)?[0] as! UITableViewCell;
    }

    cell.textLabel?.text = ((city.object(at: indexPath.row) as AnyObject).value(forKey:"title") as! NSString) as String
    cell.detailTextLabel?.text = ((city.object(at: indexPath.row) as AnyObject).value(forKey:"date") as! NSString) as String

    return cell as UITableViewCell
}

检查代码后,我发现您的问题在于没有正确解析XML数据

在获得“GetCitiesByCountryResult”的值后,您可以将其转换为xml数据并再次解析,以获得作为数组的所有城市的列表。之后,可以将其传递给viewcontroller以获得进一步的结果

let xmlArray = posts.value(forKey: "GetCitiesByCountryResult") as! [String]
let xmlString: String = xmlArray[0]

if let xml_Data:Data = xmlString.data(using: String.Encoding.utf8) {
    parser = XMLParser(data: xml_Data)
    parser.delegate = self
    parser.parse()
}

你会发送演示吗?如果你不介意的话,我会检查一下,然后带着解决方案返回给你谢谢我现在发送好了,会带着解决方案返回给你如果你输入india,那么印度的所有城市都会显示在tableview中,就像这样?是的,正是我想要的,谢谢你的回复,但是它在类型为“myTableViewController”的值的
self.reloadData()
中有错误,没有成员“reloadData”
@KrishnaCA Nop抱歉的错误
致命错误:在打开可选值时意外地发现了nil
@ViralRathod,您能给我发送您的演示吗?如果你不介意的话,我会检查一下,然后和你一起回去solution@ViralRathod,我解决了你的问题。将回复并修改上述答案,以包括solution@ViralRathod,我已将修改后的项目发送到您的电子邮件。请检查一下,让我知道
let xmlArray = posts.value(forKey: "GetCitiesByCountryResult") as! [String]
let xmlString: String = xmlArray[0]

if let xml_Data:Data = xmlString.data(using: String.Encoding.utf8) {
    parser = XMLParser(data: xml_Data)
    parser.delegate = self
    parser.parse()
}