无法在swift2中将string类型的值转换为期望的参数类型int

时间:2016-02-10 06:01:25

标签: xml web-services post soap swift2

首先,我应该说我是新手。 我使用SOAPENGINE将发布请求发送到Web服务,然后解析响应 我在Dictionary类型变量中放置响应,然后我需要在表视图中显示它的元素或值,但我无法弄清楚这个错误意味着什么以及我该如何修复它!

这是我的代码:

    struct navalist {
        //    var bullet : String!
        var Ntitle : String!
        var Speaker : String!
    }

    var tableData = [navalist]()



    var soap = [SOAPEngine]()
    var verses:NSArray = [NSArray]()

    @IBOutlet var table: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let soap = SOAPEngine()
        soap.userAgent = "SOAPEngine"
        soap.actionNamespaceSlash = true
        soap.licenseKey = "eJJDzkPK9Xx+p5cOH7w0Q+AvPdgK1fzWWuUpMaYCq3r1mwf36Ocw6dn0+CLjRaOiSjfXaFQBWMi+TxCpxVF/FA=="
        //soap.responseHeader = true // use only for non standard MS-SOAP service

        soap.setValue("Genesis", forKey: "BookName")
        soap.setIntegerValue(1, forKey: "chapter")
        soap.requestURL("http://test.com/tv/soapServices.php",
            soapAction: "http://test.com/tv/soapServices.php/getSounds",
            completeWithDictionary: { (statusCode : Int, dict : [NSObject : AnyObject]!) -> Void in

                var book:Dictionary = dict as Dictionary
//                print(book)
//                print(book["Title"])
                let soundfile : String = (book["SoundPath"] as? String)!
                let Title : String = (book["Title"] as? String)!
                let ap = navalist(Ntitle: Title, Speaker : soundfile)
                self.tableData.append(ap)

1 个答案:

答案 0 :(得分:0)

您可以将变量启动到NSArray中,然后您可以在tableview中将它们用作字符串:

 var SoundTitle:NSArray = [NSArray]()
 var soundfile:NSArray = [NSArray]()

 var book:Dictionary = dict as Dictionary
 let soundfile : NSArray = book["SoundPath"] as! NSArray
 let SoundTitle : NSArray = book["Title"] as! NSArray

 self.soundfile = soundfile
 self.SoundTitle = SoundTitle
 self.table.reloadData()