简体   繁体   中英

how can i pass soap object to one viewcontroller to another view controller in Swift-3

I am able to get response from SOAP and can also print in current viewController but i want to pass this response to secondViewController. I have tried the simple pass method but its not working.

func connectionDidFinishLoading(connection: NSURLConnection!) {
    print(mutableData)
    let xmlParser = XMLParser(data: mutableData as Data)
    xmlParser.delegate = self
    xmlParser.shouldProcessNamespaces = false
    xmlParser.shouldReportNamespacePrefixes = false
    xmlParser.shouldResolveExternalEntities = false
    xmlParser.parse()
}

// Operation to do when a new element is parsed
func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) {


    lastElementName = currentElementName
    currentElementName = elementName as NSString

    if(elementName == firstNodeName){

        elements = NSMutableDictionary()
        elements = [:]
        operation = NSMutableString()
        operation = ""
        message = NSMutableString()
        message = ""
        status = NSMutableString()
        status = ""
    }
}
// Operations to do for each element

func parser(_ parser: XMLParser, foundCharacters string: String) {

    //  print(String(format : "foundCharacters / value %@", string))
    if currentElementName == "message" {
        message.append(string)
        print(message) //I can print this response in my current ViewController But i cant pass this response to my secondViewController 

    }
    if currentElementName == "status" {
        status.append(string)
        print(status)

    }
}
let responce = NSString(data: mutableData as Data, encoding: String.Encoding.utf8.rawValue)

尝试将可变数据转换为NSString,然后将数据作为String传递给另一个UIViewController。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM