Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSXMLParser didStartElement getting attributeDict issue

I'm trying to get the attributeDict in the NSXMLParser didStartElement. My issue is I'm getting an error in calling the attributeDict (Could not find an overload for 'subscript' that accepts the supplied arguments). Am I calling the method right? I want to call all symbol keys and then add it to an array.

    func parser(parser: NSXMLParser!, didStartElement elementName: String!, namespaceURI: String!, qualifiedName qName: String!, attributes attributeDict: [NSObject : AnyObject]!)
{
    element = elementName

    if (elementName as NSString).isEqualToString("p")
    {
        println("Element's attributes are \(attributeDict)")
        //Result
        //Element's attributes are [bid: 1.16301, offer: 1.16321, symbol: EUR/USD]


        elements = NSMutableDictionary.alloc()
        elements = [:]
        title1 = NSMutableString.alloc()
        title1 = ""

        title1 = String(attributeDict["symbol"]) //Error
    }
}
like image 282
CAN Avatar asked May 29 '26 08:05

CAN


1 Answers

i hope this fix your issue

title1 = attributeDict["symbol"]! as NSMutableString
like image 59
Serkan Yılmaz Avatar answered May 31 '26 23:05

Serkan Yılmaz