打印功能没有打印所有主题

时间:2016-02-27 03:26:24

标签: ios xcode swift uitableview

我有一个快速文件Data.swift

extension NSDate {

convenience init(dateString: String) {
    let dateStringFormatter = NSDateFormatter()
    dateStringFormatter.dateFormat = "MM/dd/yyyy"
    dateStringFormatter.timeZone = NSTimeZone(name: "GMT")
    let date = dateStringFormatter.dateFromString(dateString)
    self.init(timeInterval:0, sinceDate:date!)
}

   func getDatePart() -> String {
    let formatter = NSDateFormatter()
    formatter.dateFormat = "MM/dd/yyyy"
    formatter.timeZone = NSTimeZone(name: "GMT")

    return formatter.stringFromDate(self)
   } 
}


class GDate {

let image : String
let name : String
let date: String

init(gImage : String, gName : String, gDate: String) {
    self.name = gName
    self.image = gImage
    self.date = NSDate(dateString: gDate).getDatePart()
   }
}

struct Data {

    let places = [
    GDate(gImage: "image.png", gName: "USA", gDate: "04/26/2016"),
    GDate(gImage: "image2.png", gName: "FAR", gDate: "03/26/2016"),
    GDate(gImage: "image3.png", gName: "UK", gDate: "02/26/2016"),
    GDate(gImage: "image4.png", gName: "GER", gDate: "01/26/2016")
]
}

在“cellForRowAtIndexPath”方法的tableView中

let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! GamesViewCell

    let gD = Data()
    let entry = gD.places[indexPath.row]
    let gDate = entry.date
    let image = UIImage(named: entry.image)
    cell.gameImageView.image = image
    cell.gameNameLabel.text = entry.name
    print(gDate)

    return cell

在debuger中它只打印第一个和第二个日期并忽略其余的日期?! “如果我使用它而不是日期”,则名称相同“

the debuger

0 个答案:

没有答案