I've created a custom object which contain id, name and shortname. I would like to only retrieve the id's and do a ",".join() so that it will be a string like for instance "1, 2"
So how can I convert an array like var recentArray = Array<News>() to an string with only the id's seperated by comma?
Custom Class
class Team: NSObject{
var id: Int!
var name: NSString!
var shortname: NSString!
init(id: Int, name:NSString, shortname: NSString) {
self.id = id
self.name = name
self.shortname = shortname
}
required convenience init(coder aDecoder: NSCoder) {
let id = aDecoder.decodeIntegerForKey("id")
let name = aDecoder.decodeObjectForKey("name") as! String
let shortname = aDecoder.decodeObjectForKey("shortname") as! String
self.init(id: id, name: name, shortname: shortname)
}
func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeInteger(id, forKey: "id")
aCoder.encodeObject(name, forKey: "name")
aCoder.encodeObject(shortname, forKey: "shortname")
}
}
initanyway?