我正在尝试在NSXMLParser didStartElement中获取attributeDict。我的问题是我在调用attributeDict时遇到错误(找不到接受提供的参数的'subscript'的重载)。我称该方法正确吗?我想调用所有符号键,然后将其添加到数组中。
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
}
}
最佳答案
我希望这可以解决您的问题
title1 = attributeDict["symbol"]! as NSMutableString
关于ios - NSXMLParser didStartElement获取attributeDict问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27981454/