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

  • Home
  • SEARCH
  • 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 6018529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:17:19+00:00 2026-05-23T03:17:19+00:00

I am trying to open a small text file to test some NSFileHandle functions

  • 0

I am trying to open a small text file to test some NSFileHandle functions on the file. however I cannot figure out how to do this, if you could tell me what I am missing that would be great.

//.h

@interface MainViewController : UIViewController <FlipsideViewControllerDelegate> {
    NSFileHandle *nCode;
}
@property (nonatomic, retain) IBOutlet NSFileHandle *nCode;

- (IBAction)showInfo:(id)sender;

//check for code
- (void)fetchCode:(id)sender; //this function is attached to a button in the .nib

@end

//.m

- (void)fetchCode:(id)sender{
nCode = [NSFileHandle fileHandleForReadingAtPath:@"nCode01.txt"];

if (nCode == nil) {
    NSLog (@"Open of nCode for reading failed\n");
    return;
}

 [nCode closeFile];
}

all I am doing here is trying to open the file, however each time I press the button I recive the error message “Open of nCode for reading failed”… what am I doing wrong ?

from this I am hoping to find a way to let the user enter a number which represents a line in the text file and then return the text that is in that line.. dose anyone know a way of doing that? is it possible?

  • 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-23T03:17:19+00:00Added an answer on May 23, 2026 at 3:17 am

    Most likely the problem is the file path since you’re not specifying a full path name. When you want to access a file inside your application bundle, use -[NSBundle pathForResource:ofType]:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"nCode01"
                                                     ofType:@"txt"];
    nCode = [NSFileHandle fileHandleForReadingAtPath:path];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read the contents of a small text file using the common
im trying to open a file using StreamReader and ive to set a Encoding,
I'm trying to open a folder in explorer with a file selected. The following
I'm trying to open a file and create a list with each line read
I'm trying to open a Microsoft Excel file in a C# program using the
I got this error today when trying to open a Visual Studio 2008 project
Is there a better way than simply trying to open the file? int exists(const
All of a sudden I start getting this error while trying to open 2
Here's some background on what I'm trying to do: Open a serial port from
I am trying to serialize a list of dictionaries to a csv text file

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.