How would I go about creating a new text file in my program so that I can write content to it? I already understand how to write content but I haven't been able to find anything (anything easy to understand) on the subject.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- What is the best way to do a search in a large fil
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- What is the correct way to declare and use a FILE
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
You can use UITextView to write text
save the file using
Get the TextFile content using
Your question is so broad one could drive a truck (or lorry, in UK English) through the middle of it.
But in general, you could add a UITextView to one of your view controllers.
And when you are ready to save, you could take the contents of the text view (which is a NSString), and save it to a file via the NSString writeToFile methods.
And you can load the text view later on via NSString's "initFromFile" method, as long as you know the path to that file.
Here are other questions that people have asked that may help you out.
Use this method:
An example:
Write to a file works this way: Use this method:
Example:
Mistake:
Can't just write to bundle path. Need to copy it to Documents Directory.