I found answers to my question in Objective C but couldnt find it in Swift. How can I make the code below work in terms of adding a String value to an NSMutableString? It throws "length only defined for abstract class" error.
This code is aimed to parse an xml feed and write it to a NSMutableDictionary()
var ftitle = NSMutableString?()
func parser(parser: NSXMLParser!, foundCharacters string: String!) {
if element.isEqualToString("title") {
ftitle?.appendString(string)
}
}
Edit: Here is more context;
element is NSString which is assigned to elementName in parser during DidStartElement. in this code, i catch the "title" of the feed content via element.
i have an NSMutableDictionary() which includes different NSMutableString() such as ftitle. this piece of code is to add the string to the ftitle, which is NSMutableString, then it will be part of NSMutableDictionary, and finally i will read it to write in my tableviewcells
here is didStartElement method:
func parser(parser: NSXMLParser!, didStartElement elementName: String!, namespaceURI: String!, qualifiedName qName: String!, attributes attributeDict: [NSObject : AnyObject]!) {
element = elementName
if (element as NSString).isEqualToString("item"){
elements = NSMutableDictionary.alloc()
elements = [:]
ftitle = NSMutableString.alloc()
link = ""
fdescription = NSMutableString.alloc()
fdescription = ""
}
}