Swift TableView单元格:如何将Integer更改为String

时间:2015-11-13 20:18:39

标签: xcode parse-platform swift2

如何将其更改为String,以便在laps单元格字段中看到它?

let query = PFQuery(className:"Participant")
   query.whereKey("school", equalTo:userSchool)
    query.findObjectsInBackgroundWithBlock({ (objects, error) -> Void in

        if let objects = objects {
            for object in objects {
                self.participantId.append(object.objectId! as String)
                self.firstname.append(object["firstname"] as! String)
                self.lastname.append(object["lastname"] as! String)
                self.laps.append(object["laps"] as! NSInteger)

}

那么我如何从上面取出self.laps.append(object["laps"] as! NSInteger)并将其变成一个字符串以放入如下的单元格标签。

cell.lapLabel.tag = self.laps[indexPath.row] as NSInteger!;

我见过:

let myInteger = 5
let myString = "\(myInteger)"

但我对如何将其应用到上述内容感到困惑。

1 个答案:

答案 0 :(得分:0)

我不确定你在问什么。如果要将整数放入字符串中,可以这样做:

let myInteger = 5
let myString = "\(myInteger)"