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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:58:26+00:00 2026-05-24T19:58:26+00:00

I am new to iPhone and i am creating an iPhone app in which

  • 0

I am new to iPhone and i am creating an iPhone app in which i am using simple text file as my database.
In firstView i have four UIButtons. I have four different text file.
What i want is when i select button1 then data from file1.txt will be load same as when i select button2 , button3 and button4 , data from file2 ,file3 ,file4 will be load respectively.

Something like this :

if(categoryVC.Quiz1btn isSelected == YES){
NSBundle *bundle = [NSBundle mainBundle];
NSString *textFilePath = [bundle pathForResource:@"file1" ofType:@"txt"];
NSString *fileContents = [NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil];
[NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil];
NSArray *quizArray = [[NSArray alloc] initWithArray:[fileContents componentsSeparatedByString:@"\n"]];
self.theQuiz = quizArray;
}

but this is not working.

Any Help will be appreciated.

Thank you.

  • 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-24T19:58:27+00:00Added an answer on May 24, 2026 at 7:58 pm

    What you can do is to add an (NSString*) filename attribut in your second viewController and pass the name of the selected file button as following in the fisrt view controller :

    -(IBAction)selectFile1Action:(id)sender {
    SecondViewController *scView = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:nil];
    scView.filename = @"file1";
    [[self navigationController] pushViewController:scView animated:YES];
    [scView release];
    

    }

    and so one …

    And in viewDidLoad function of the second view controller you add the following code :

    - (void)viewDidLoad {
    
    [super viewDidLoad];
    NSBundle *bundle = [NSBundle mainBundle]; 
    NSString *textFilePath = [bundle pathForResource:filename ofType:@"txt"]; 
    NSString *fileContents = [NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil]; 
    [NSString stringWithContentsOfFile:textFilePath encoding:NSUTF8StringEncoding error:nil]; 
    NSArray *quizArray = [[NSArray alloc] initWithArray:[fileContents componentsSeparatedByString:@"\n"]]; 
    self.theQuiz = quizArray;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an iPhone app and would like to have a simple text
I'm creating an app in which I want to have a new set of
I am new to the iphone platform and am creating an app that retrievals
friends, I am new to Iphone development, I am creating a simple analog clock,
When creating a new message using Mail on the iPhone, and after typing the
I’m writing a new iPhone app which doesn’t depend on any of the 3.0
I have a new iPhone app that has the following (and only the following)
I'm new to iPhone dev. My app is dynamically creating buttons, following from my
I am new to iPhone development. I am creating an app where I take
I'm creating an app for the iPhone which is supposed to start in camera

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.