XCode Tutorial: Reading A Text File

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
17,645
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Nov 1, 2009

In this tutorial, I explain how to open a text file in a text view or label. This can be used to store usernames, passwords, and more. You can even make an eBook easier than ever!

Check out WiiDG!
http://youtube.com/WiiDG

----------------------------------------------------------------------

For shout-outs, blog advertising and more, check out the "Advertise" page on my blog.

http://blog.simplesdk.com/index.php/advertise/

----------------------------------------------------------------------

Other Links:

http://twitter.com/SimpleSDK
http://blog.simplesdk.com

  • likes, 8 dislikes

Link to this comment:

Share to:
see all

All Comments (34)

Sign In or Sign Up now to post a comment!
  • (continued from below) Then in the implementation file, synthesize the label. in the ViewController.xib, drag a label on the view, right click it, and drag the New referencing outlet to File's owner and click [your label name]. hope this helps!

  • Note to Xcode4 users:

    there is already a view did load method in the file. you just need to add this to it: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"txt"]; [super viewDidLoad]; if (filePath) { NSString *textFromFile = [NSString stringWithContentsOfFile:fileP­ath]; label.text = textFromFile;

    in the header file, add a UILabel. then add the following:

    @property (nonatomic, retain) IBOutlet UILabel *label;

  • @araz01000 i was being sarcastic right now i got money on my MONEY so screw your sht of tutorial which dates back to 1999

  • Thanks for your help

  • but i don't know what to add it as a PDF, txt, html ??

  • i'm trying to make a dictionary i need to add the 600paged pdf file :I

  • This is a great video. I am very impressed at your knowledge of iPhone development and especially the simplicity with which you present your tutorials. I learn better from you than I have from "college" courses.

    I was wondering about this tutorial if there is a way to randomize text messages so that a different message can be displayed each time the app is launched or perhaps once a day.

    I'm thinking of maybe an html feed with timed messages. What do you think is best?

  • @joy1819 one of the letters in that: ContentsofFile should be Upper case --> OfFile rather than ofFile. i did the same lols

  • I get a warning saying that 'NSString' may not respond to '+stringWithContentsofFile:' (messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments). Also, the text file is not displayed. I have exactly the same code as you. Ideas?

  • Thumbs up! ...It's not often that I need help, but I was stuck on this topic for a long time. Does anyone know how I would get the contents of a text file somewhere else on my hard drive? Thanks.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more