Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show answers of a flashcard type programmed iPhone app between two arrays, xcode?
    text
    copied!<ul> <li>I'm trying to display questions in a viewcontroller using storyboards and when the user clicks show answer. It brings it from view<br> controller to another. The other view controller just shows the<br> answer and has a back button. </li> <li>Both viewcontrollers use the same<br> class. The user can toggle next and previous from one string to<br> another in the app from the question.</li> <li>When I click show answer on first question, I<br> can see the first string in the answers array which says lol but when I go the next<br> question and I click show answer it says the same the answer.</li> <li>I linked the ib action showanswer but it did does not seem to have any effect. The Show Answer button goes to the other view controller<br> through a segue and also has the ib action show answer linked to it.</li> </ul> <p>So my question is what am I doing wrong in the ib action showAnswer? If I am approaching this flashcard type application wrong, what am I doing wrong?</p> <pre><code>// // BiologyViewController.m // Biology // // Created by Jacob Brans on 6/6/13. // Copyright (c) 2013 Jacob Brans. All rights reserved. // #import "BiologyViewController.h" @interface BiologyViewController () @end @implementation BiologyViewController @synthesize labelsText; @synthesize textView, textViewanswer1; -(void)viewDidLoad { [super viewDidLoad]; titles = [NSArray arrayWithObjects:// Time Together @"What is Biology?",@"What is yo mamma?",nil]; step= 0; textView.text = [titles objectAtIndex:step]; answers = [NSArray arrayWithObjects:// Time Together @"lol",@"wow",nil]; textViewanswer1.text = [answers objectAtIndex:step]; labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count]; } -(IBAction)showanswer:(id)sender{ textViewanswer1.text = [answers objectAtIndex:step]; } -(IBAction) nextclicked:(id)sender{ // titles = [NSArray arrayWithObjects:@"iology is the scientific study of life. Bam",@"This works? Wow",@"lol", nil]; if (step&lt;titles.count-1) { step++; } else { step= 0; } textView.text = [titles objectAtIndex:step]; labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count]; } -(IBAction) prevClicked:(id)sender{ // titles = [NSArray arrayWithObjects:@"Biology is the scientific study of life. Bam",@"This works? Wow",@"Still Works.",@"garret is the coolest awesome person awesome wowowowwwwwwwwwwwwwwwwwwwwwwwwwww", nil]; if (step&gt;0) { step--; } else { step =titles.count-1; } textView.text = [titles objectAtIndex:step]; labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count]; } -(IBAction) randomClicked:(id)sender{ step = 1+arc4random() %(titles.count); textView.text = [titles objectAtIndex:step]; labelsText.text = [NSString stringWithFormat:@"%d/%d", step+1, titles.count]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload