我有一个SwiftyJson数据数组,我已经声明并用数据填充它.我用来填充hoge数组的代码是这样的: self.hoge = JSON(data: data!)
但是我需要将新的swiftyJSON数据附加到这个hoge数组.我注意到hoge数组没有append属性.我该怎么办?
谢谢
我是swift编程的新手,我已经搜索了很多关于使用Swift存储NSCache图像的方法.
到目前为止我所做的是,我正在使用JSON 获取ids和imageNames,我将数据存储在数组中,并且能够在单元格中显示图像而没有任何问题.现在我想缓存图像.这是我写的代码:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as TableViewCell
//cell.imageView
nameID = self.hoge[indexPath.row]["cars"]["carid"].string!
cell.nameLabel.text = nameID
if let imageFileURL = imageCache.objectForKey(self.hoge[indexPath.row]["cars"]["carid"].intValue) as? NSURL {
println("Get image from cache")
} else {
imageName = self.hoge[indexPath.row]["cars"]["pic_name"].string!
// If the image does not exist, we need to download it
var imgURL: NSURL = NSURL(string: "http://192.168.1.35/car/uploads/" + imageName )!
var image:UIImage = UIImage(named: "pen")!
// Download an NSData …Run Code Online (Sandbox Code Playgroud)