小编use*_*956的帖子

如何将新数据附加到现有JSON数组(swiftyJSON)

我有一个SwiftyJson数据数组,我已经声明并用数据填充它.我用来填充hoge数组的代码是这样的: self.hoge = JSON(data: data!)

但是我需要将新的swiftyJSON数据附加到这个hoge数组.我注意到hoge数组没有append属性.我该怎么办?

谢谢

arrays json ios swift swifty-json

11
推荐指数
4
解决办法
2万
查看次数

NSCache存储UITableView的图像在Swift中

我是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)

uitableview ios nscache swift

1
推荐指数
1
解决办法
5700
查看次数

标签 统计

ios ×2

swift ×2

arrays ×1

json ×1

nscache ×1

swifty-json ×1

uitableview ×1