NSXMLParser问题Swift

时间:2015-03-23 05:02:23

标签: swift nsxmlparser

我的问题是当我尝试将我的didEndElement中的字符串打印到控制台时,除了从func解析器(解析器:NSXMLParser!,foundCharacters string:String!)打印时,我什么也得不到。我得到控制台输出。但显然这不是正确的做事方式......在我的didEndElement方法中没有得到控制台输出的地方我做错了什么?

var descString = NSMutableString()


func parser(parser: NSXMLParser!, didStartElement elementName: String!, namespaceURI: String!, qualifiedName qName: String!, attributes attributeDict: NSDictionary!) {
        currentElementName = elementName
        if (elementName as NSString).isEqualToString("item") {
            descString = ""
    }

    func parser(parser: NSXMLParser!, foundCharacters string: String!) {
        if (seperateSoap == "skuString") {
            if currentElementName.isEqualToString("description") {
                descString.appendString(string)
            }
        }
    }

    func parser(parser: NSXMLParser!, didEndElement elementName: String!, namespaceURI: String!, qualifiedName qName: String!) {
        if (elementName as NSString).isEqualToString("item") {
            if (seperateSoap == "skuString") {
             if !descString.isEqual(nil) {
                descLabel.text = descString
             }
          }
     }
}

0 个答案:

没有答案