TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Day 16 - Followed all steps exactly and simulator still produces a blank screen

Forums > 100 Days of SwiftUI

Day 16 starts off with some work-arounds as the Single View App option doesn't exist anymore for creating a project, so I had to manually seek out how to enable the storyboard and got set up that way. I got all the way to part 3 following the code word for word, line for line, and at the very end when the instructions say that a table view should be appearing on the simulator now, it's still blank for me.

2      

Hi! I assume you are following the original course 100 Days of Swift, since you are using Storyboard file. This forum covers another course i.e. 100 Days of SwiftUI. Nevertheless, could you provide sample code at least so that others can look into possible issues there?

2      

I'll post the code below, but as an update, I continued following the guide pretending nothing was wrong. Once I got to the part where the table is supposed to present the image names, my table appeared and everything was working. But I'm still curious as to why the blank table didn't show up initially like it was supposed to. Here's the code:

// // ViewController.swift // Project1 // // Created by * on 8/15/23. //

import UIKit

class ViewController: UITableViewController { var pictures = [String]()

override func viewDidLoad() {
    super.viewDidLoad()

    let fm = FileManager.default
    let path = Bundle.main.resourcePath!
    let items = try! fm.contentsOfDirectory(atPath: path)

    for item in items {
        if item.hasPrefix("nssl") {
            pictures.append(item)
        }
    }
    print(pictures)
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return pictures.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Picture", for: indexPath)
    cell.textLabel?.text = pictures[indexPath.row]
    return cell
}

}

2      

Well there are many reasons that may lead to such kind of result. Withouth seeing the intial code that triggered that behavior it is difficult to say :)

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.