79457045

Date: 2025-02-21 10:28:01
Score: 3.5
Natty:
Report link

I think you should debug firstly, can you catch the file and then can you use it. If all statements are working, can you provide more codes to explain it ?

func startGame() {
    // Check if the file "start.txt" exists in the main bundle
    if let startWordsURL = Bundle.main.url(forResource: "start", withExtension: "txt") {
        print("File found: \(startWordsURL)") // Debugging statement
        
        do {
            // Try to read the content of the file
            let startWords = try String(contentsOf: startWordsURL, encoding: .utf8)
            let allWords = startWords.components(separatedBy: "\n")
            
            // Debugging statement to print all words loaded from the file
            print("Words loaded: \(allWords)") 

            // If you want to set a random word as the rootWord
            // rootWord = allWords.randomElement() ?? "november"
            
        } catch {
            // If there's an error reading the file, print the error
            print("Error reading file: \(error)")
        }
    } else {
        // If the file wasn't found, print a message
        print("File 'start.txt' not found in the bundle.")
    }
}
Reasons:
  • RegEx Blacklisted phrase (2.5): can you provide
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: blackhatsrak