1

I have a TopicsViewController which displays UIButtons labeled by popular research topics for students.

TopicsViewController:

enter image description here

TopicsViewController.m has a prepareForSegue method successfully passing data to my StatsViewController, which displays UIButtons labeled by statistics for the selected topic. These statistics are NSStrings passed from the TopicsViewController class into NSString properties in the StatsViewController class.

In TopicsViewController.m:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {



if ([segue.identifier isEqualToString:@"abortionSeg"]) {

    StatsViewController *statScreen = [segue destinationViewController];


    NSString *abortStatistic1 = @"this is a stat", *abortStatistic2 = @"this is a stat", *abortStatistic3 = @"this is a stat", *abortStatistic4 = @"this is a stat", *abortStatistic5 = @"this is a stat", *abortStatistic6 = @"this is a stat", *abortStatistic7 = @"this is a stat", *abortStatistic8 = @"more stats to come";

    statScreen.strStat1 = abortStatistic1;
    statScreen.strStat2 = abortStatistic2;
    statScreen.strStat3 = abortStatistic3;
    statScreen.strStat4 = abortStatistic4;
    statScreen.strStat5 = abortStatistic5;
    statScreen.strStat6 = abortStatistic6;
    statScreen.strStat7 = abortStatistic7;
    statScreen.strStat8 = abortStatistic8;

    statScreen.statWhichTopic = @"abortion";
}
else if ([segue.identifier isEqualToString:@"agricultSeg"]) {...}

StatsViewController:

enter image description here

StatsViewController.m has a prepareForSegue method successfully passing data to my CiteViewController, which displays UIButtons labeled by MLA and APA citations for the selected statistic. These citations are passed in the same way as the statistics are from one class to another.

In StatsViewController.m:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    //stat1 data... COMPLETE
    if ([segue.identifier isEqualToString:@"stat1Seg"]) {

        CiteViewController *citeScreen = [segue destinationViewController];

        citeScreen.citeWhichStat = @"1";

        if ([statWhichTopic isEqualToString:@"abortion"]) {
            citeScreen.strMLA = @"Mantel, Barbara. \"Abortion.\" CQ Researcher 19 May 2015. Web. 4 Mar. 2016.";
            citeScreen.strAPA = @"Mantel, B. (2015, May 19). Abortion. CQ Researcher. Retrieved from http://library.cqpress.com.ezaccess.libraries.psu.edu/";

            citeScreen.citeWhichTopic = @"abortion";
        }
        else if ([statWhichTopic isEqualToString:@"agriculture"]) {..}

CiteViewController:

enter image description here

The Cite page then passes a URL on to a SourceViewController to display a UIWebView associated with the source, but there are no issues with this page.

Issues:

When tapping the “< Hot Topics” button on the Stats page (segues back to TopicsViewController), the app crashes and the exception breakpoint falls on the following line:

enter image description here

The debugger shows the UIButtons on TopicsViewController are nil:

enter image description here

When tapping the “< Statistics” button on the Cite page (segues back to StatsViewController), the app crashes and the exception breakpoint falls on the following line:

enter image description here

The debugger shows the NSStrings on StatsViewController are nil:

enter image description here

This is all I have found. Thank you in advance for any replies, much appreciated.

  • Did u make segue to move forward and to move backward separately? – Tj3n Jul 19 '16 at 04:53
  • What is "citeWhichState"? It seems, that it either not properly declared or have garbage value? – WasimSafdar Jul 19 '16 at 05:16
  • What does first 2 line of crash log say? – rptwsthi Jul 19 '16 at 05:46
  • @Tj3n yeah, separate segues, one being connected from the back button to the previous view. @WasimSafdar `citeWhichStat` passes through each class to identify which stat has been selected, in addition to which topic. This way the appropriate content can be passed. @rptwsthi `self = (StatsViewController *) 0x7fb66b45b620` and `segue = (UIStoryboardSegue *) 0x7fb66b50f390` are the first two lines. – user3884788 Jul 19 '16 at 17:24
  • separate segue is wrong, if you want to come back to the last screen, use delegate or unwind segue – Tj3n Jul 20 '16 at 02:46
  • @Tj3n okay, I'm going to try to implement an unwind segue based on the instruction on http://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-do-you-use-them . I'll post here whether it fixes the issue or not. Thank you for your help! – user3884788 Jul 20 '16 at 03:48
  • @Tj3n unwind segue is not working currently. I have established the method and connected the back button to Exit, but the app continues to crash. I do not understand what is meant to be put inside of the segue method since I am not handling data anymore, just returning to the past view controller. – user3884788 Aug 05 '16 at 02:14

0 Answers0