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 3840782
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:34:10+00:00 2026-05-19T15:34:10+00:00

I am creating an iOS app which reads in a text file and displays

  • 0

I am creating an iOS app which reads in a text file and displays the contents in a UIText field.

For the 1st three consecutive runs of thee app (Restarting a new session without exiting),
the data is read in fine. However on the fourth attempt, the data returned from the file is all nulls.

I’ve verified the file integrity. The issue exists when using stringWithContentsOfFile or initWithContentsOfFile.

After many hours of troubleshooting, I believe the issue is somehow related to a buffer being cleared within the above mentioned methods.

Any insight regarding this issue is greatly appreciated. I’ve tried many things with no luck.

Here’s the code I use to read in the file:

TheString = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]     
pathForResource:@"My_TextFile" ofType:@"txt"] encoding:NSUTF8StringEncoding error:NULL];

Here’s the code I use to display certain contents of the file (The contents are placed in an array of type NSArray):

NSArray *My_Array;

My_Array= [TheString componentsSeparatedByString:@"\n"];

/* Obtain specific data to display */
    DisplayedData = [My_Array objectAtIndex:M[l]-1];
:
:
/* Display the data in the view */
    MyUITextView.text = DisplayedData;

/* Log the data */
    NSLog(@"%@", MyUITextView.text);

On the 4th invocation of the code above, the data returned is blank and NSLOG is returning nulls

Thanks so much for any help!

  • 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-19T15:34:11+00:00Added an answer on May 19, 2026 at 3:34 pm

    Maybe I’m a little bit late with answer, but, anyway, maybe somebody will find it useful.
    OK, I have also spent a day trying to figure out why my custom class for scrollable view is working 3 times and refuse at the 4-th time… I found that the problem has quite the same attributes as yours: nested NSString objects unexpectedly disappear. Though pointers point to the same address in memory, memory is already filled with quite arbitrary objects instead my NSStrings.
    And I paid attention that I created these NSStrings using the following class method:

    + (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc  error:(NSError  **)error
    

    So, I’m not the owner of these NSStrings.
    And I assumed that to be the owner can be a solution, so I created my NSStrings through alloc and

    - (id)initWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc  error:(NSError  **)error 
    

    instance method.

    App was repaired!

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

Sidebar

Related Questions

1)I am creating a ios app in which I have to scan a pool
I am currently creating an iOS app, which connects to a database and asynchronously
We are creating an ios app, In which we want to use certain interactive
Creating an iOS app in Flash Builder 4.5 which is a small Hello World
I am creating an iOS app that displays a web view. How can I
I am creating an iOS app which uses both ASIHTTPRequest and ShareKit. Both APIs
Problem : I am creating an iOS chat app using the XMPPFramework and an
I am creating a quiz style app for iOS using phonegap. The app allows
I'm creating an app that tracks your elevation. Currently IOS is one of the
I'm in the process of creating a universal iOS app that, amongst other functions,

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.