First off, I’m a complete beginner.
That said, I thought an ambitious longer-term project/learning experience would be to create an app that displayed daily quotes, like those cheesy day-by-day calendars our grandmothers have in their bathrooms. I want it to have two per day, each one represented by a tab in a UISegmentedControl. That’s the long term. Right now I’d be happy with getting a single day’s worth of quotes functioning.
Onto the questions:
-
How can I get text saved in a .txt or .rtf file to be displayed in a UITextView? Preferably without using ‘stringWithContentsOfFile,’ since Xcode is telling me that’s deprecated.
-
How can I get content from a different file (or maybe a different portion of the same file…?) to be displayed when the user taps the second segment?
If I can get it running so that those two conditions are met and I understand what’s going on, I’ll consider the day a success. Thanks!
1.
The error and encoding are optional, and you can pass in nil for both. But if you care about the error, or what encoding the file was in they will have useful info in them after the string is created.
2.
Set the
valueChangedoutlet in Interface Builder to an IBAction on your controller, such assetSegmentValue:. Then, assuming you have an array of quote strings: