I have tried to write the app that data can be shown form Json and displayed in collectionview but the problem is only text can be displayed but not the pictures. Can anybody assist, or give me some advice?
var collection = [LabelClass]()
let kiaLoandURL = "http://xxxx.com/?json=get_recent_posts/json=1&count=10&custom_fields=PostThumb&include=title,content,thumbnail"
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as CustomCollectionViewCell
cell.nameLabel.text = collection[indexPath.row].title
cell.nameImage.image = UIImage(named: collection[indexPath.row].image) // not working
return cell
}
func parseJsonData(data:NSData) -> [LabelClass] {
var info = [LabelClass]()
var error:NSError?
let jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &error) as? NSDictionary
if error != nil{
println(error?.localizedDescription)
}
let json = jsonResult?["posts"] as [AnyObject]
for jsonLoad in json {
let data = LabelClass()
data.title = jsonLoan["title"] as String
data.image = jsonLoan["thumbnail"] as String
info.append(data)
}
return info
}