-1

Before you down vote, I haven't found anything that looks like this.

So i made a few text files, each is labeled a specific number(corresponding to the day of the month). Each text file has a quote embedded inside. I had it such that when the button is pressed on the view the label that says "Historical" changes to that quote.

Here is the code:

@IBAction func UpdateHistorical(sender: AnyObject) {//step 1
    let a = NSCalendar.currentCalendar().component(.Day, fromDate: NSDate())
    HistoricalLabel.text = String(a)
    var n = ""
    n = String(a)
    let hImage = UIImage.init(named: n)
    HistoricalImage.image = hImage

 //Below is the part that matters above was to just give context

    let path = NSTemporaryDirectory()+"1.txt"

    let readFile = try? String(contentsOfFile: path, encoding: NSUTF8StringEncoding)

    HistoricalLabel.text = readFile

}

}

Here is an image of the view: enter image description here

Here is an image of the view after execution: enter image description here

What am I doing wrong?

Nick3150
  • 21
  • 6

1 Answers1

1

Label is not gone but you are setting empty string i think. You got empty string while reading text file.

Bhadresh Mulsaniya
  • 2,610
  • 1
  • 12
  • 25