Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 341725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:44:08+00:00 2026-05-12T10:44:08+00:00

I am fairly new to a objective-c or in whole mac/iphone development. My question

  • 0

I am fairly new to a objective-c or in whole mac/iphone development. My question is how can I acces a data files(text files or flat files) in objective-c? For example I have a sample.txt file, how can I open this files and access its data? Do I need to use a class? And I heard about dictionary, is this term related to my problems?

Please kindly redirect me to a good site.

Thanks alot.

sasayins.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:44:09+00:00Added an answer on May 12, 2026 at 10:44 am

    You can use regular fopen and fread to access the contents of a file. Alternatively, you can use NSString if your file contains only text or NSData for non-text data.

    NSString *myString = [NSString stringWithContentsOfFile:@"/path/to/file"];
    
    NSData *myData = [NSData dataWithContentsOfFile:@"/path/to/file"];
    

    Edit

    @"/path/to/file" a constant “Objective-C” style string. It is different to a regular C string (i.e. without the @ prepended) because it behaves like an object; you can send it messages, and it is able to be stored in NSArrays etc. From a Mac Programmer’s point of view, these Objective-C strings can be treated just like NSString objects.

    The Mac OS X filesystem layout typically looks like this:

        /System          contains system files similar to C:\windows\
        /Library         contains libraries, similar to C:\windows\system32\
        /Users           similar to Windows' C:\Documents and Settings\
        /Applications    Mac's version of C:\Program Files\
        /Developer       Where Xcode, SDKs, and other developer tools live.
    

    If your username on your Mac is “smith”, then your Home directory is /Users/smith. If you have a file in your Documents folder of your Home directory called data.txt, then you can use the following code to access it (but I wouldn’t recommend hard-coding paths like this)

    NSString *myString = [NSString stringWithContentsOfFile:@"/Users/smith/Documents/data.txt"];
    

    There are various functions available for reliably obtaining your home directory and other directories of particular interest. The NSString documentation explains the various methods available for manipulating strings containing paths.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being fairly new to iPhone / Objective-C development, I wanted to ask this question
I'm fairly new to Objective-C and I can't figure out how to wait in
I'm fairly new to Objective-C and iPhone programming so I apologize if this is
fairly new to Objective-C and iOS development (coming from PHP) and I have a
Fairly new to Objective C and trying to work within Storyboards given it's the
I am fairly new to objective-c and am having trouble understanding the warning message
I am fairly new to Objective-C and whilst running the Clang static analyser this
I'm fairly new to objective-c, and am looking to pass a number of key-value
I'm fairly new to Objective-C and cocoa programming, so I don't really understand the
As a disclaimer I'd like to state that I'm fairly new to Objective-C and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.