Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7188

Does UIImages allow Int Ranges to import the UITableView cells indexPath.row? [closed]

$
0
0

I love to find the tricks the methods to use it successfully with UITableView, basically. I discovered the code has crashed it. I've check debug and it shows up the crash report at comic_IMG behind the ranges has says the value was nil.

Alright, let me show you.

I imported the images with titles is 1 to 5 in the Assets.xcassets folder.

Then

Put the code before viewDidLoad()

var comic_IMG = [1...5]

UITableView Code

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {      var comicsCells: EpisodeOneTableViewCell!      var AdMod: AdModTableViewCell!      if indexPath.row == 1 {           // Not worried about this, it was simple to code.           AdMod = EOneTableView.dequeueReusableCell(withIdentifier: "AdMod") as? AdModTableViewCell           AdMod.backgroundColor = .red           return AdMod    } else if indexPath.row == 19 {            // Not worried about this, it was simple to code.            FollowCells = EOneTableView.dequeueReusableCell(withIdentifier: "Follows") as? FollowTableViewCell            FollowCells.FollowImg.image = UIImage(named: "Follows")            return FollowCells.FollowImg.image    } else {           // MARK: ISSUES            comicsCells = EOneTableView.dequeueReusableCell(withIdentifier: "Comics") as? EpisodeOneTableViewCell            // This shows up crash cuz of won't read the ranges.            comicsCells.IMG.image = UIImage(named: "\(comic_IMG[indexPath.row])")            return comicsCells    }}

Have you known any of the tricks to reading the ranges in the indexPath.row? it is because I like to move faster to code it! Thanks!


Viewing all articles
Browse latest Browse all 7188

Trending Articles