iPhone Programming: Reading Plain Text Files into your app.

Опубликовано: 23 Февраль 2026
на канале: MilmersXcode
7,704
20

A tutorial teaching you how to read text form an external plain text file and put it into a UITextView

IMPORTANT: IT MUST BE A PLAIN .TXT FILE. If your textEdit will not allow you to save as .txt and says it must be a .rtf or .txt.rtf go to this link to change your textEdit preferences. Its an apple support page.

http://support.apple.com/kb/ta20406

When you save your textFile choose "Unicode (UTF-8)" or "(UTF-16) as Plain Text Encoding. You will have to modify all existing .rtf files you wish to use.

Main code used:

//If you chose UTF-16 change to NSUTF16StringEncoding
text.text = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"YourFileName" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];

Twitter:   / failcakeapps  
Apple Developer Center: http://developer.apple.com/devcenter/...
Website: http://failcake.webs.com/
Channel:    / milmersxcode