My image exists in as tableView Cell so I am using the following code to make changes to it: (I am updating image from cache if there is any confusion below)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if let nimage = cell.viewWithTag(111){ // 111 is a UIImageView
nimage.image = imageCache[urlString]
// above error - nimage has no member named image
nimage = imageCache[urlString]
// above error - cannot assign to 'let' value 'UIImage'
}
what do I do?
Type casting is a must here
if let nimage:UIImageView = cell.viewWithTag(111) as! UIImageView{ // 111 is a UIImageView
nimage.image = imageCache[urlString]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.