0
votes

It is very long method and it got a bit messed up trying to cut it out so StackOverflow allows me to post so much.

StatsViewController prepareForSegue method:

`-(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"]) {
        citeScreen.strMLA = @"\"Nitrogen.\" CropNutrition.com. The Mosaic Company, 2013. Web. 30 Apr. 2016.";
        citeScreen.strAPA = @"CropNutrition.com. (2013). Nitrogen. Retrieved April 30, 2016, from http://www.cropnutrition.com/efu-nitrogen#overview";

        citeScreen.citeWhichTopic = @"agriculture";
    }
    else if ([statWhichTopic isEqualToString:@"climateChange"]) {
        citeScreen.strMLA = @"\"Causes of Climate Change.\" EPA: United States Environmental Protection Agency, 23 Feb. 2016. Web. 12 Apr. 2016.";
        citeScreen.strAPA = @"EPA. (2016, February 23). Causes of Climate Change. Retrieved April 12, 2016, from https://www3.epa.gov/climatechange/science/causes.html";

        citeScreen.citeWhichTopic = @"climateChange";
    }
    else if ([statWhichTopic isEqualToString:@"cybersecurity"]) {
        citeScreen.strMLA = @"\"Top Cybersecurity Statistics for 2016 - Cyber Security Marketing Blog.\" Cyber Security Marketing Blog. Penguin Strategies, 17 Jan. 2016. Web. 16 Apr. 2016.";
        citeScreen.strAPA = @"Penguin Strategies. (2016, January 17). Top Cybersecurity Statistics for 2016 - Cyber Security Marketing Blog. Retrieved April 16, 2016, from http://www.marketingcybersecurity.com/2016-cybersecurity-statistics/";

        citeScreen.citeWhichTopic = @"cybersecurity";
    }
    else if ([statWhichTopic isEqualToString:@"discrimination"]) {
        citeScreen.strMLA = @"Logan, John R. \"Separate and Unequal: The Neighborhood Gap for Blacks, Hispanics and Asians in Metropolitan America.\" (n.d.): n. pag. Report0727. US2010: Discover America in a New Century, July 2011. Web. 22 Apr. 2016.";
        citeScreen.strAPA = @"Logan, J. R. (2011, July). Separate and Unequal: The Neighborhood Gap for Blacks, Hispanics and Asians in Metropolitan America. Retrieved April 22, 2016, from http://www.s4.brown.edu/us2010/Data/Report/report0727.pdf";

        citeScreen.citeWhichTopic = @"discrimination";
    }
    else if ([statWhichTopic isEqualToString:@"education"]) {
        citeScreen.strMLA = @"\"Fast Facts- Career and Technical Education.\" National Center for Education Statistics. U.S. Department of Education, Institute of Education Sciences, n.d. Web. 27 Apr. 2016.";
        citeScreen.strAPA = @"National Center for Education Statistics. (n.d.). Fast Facts- Career and technical education. Retrieved April 27, 2016, from https://nces.ed.gov/fastfacts/display.asp?id=43";

        citeScreen.citeWhichTopic = @"education";
    }
    else if ([statWhichTopic isEqualToString:@"energy"]) {
        citeScreen.strMLA = @"\"India's Crude Oil Imports Rose 7% in 2015-16 as Consumption Grew by 11%.\"Enerdata. Enerdata, 22 Apr. 2016. Web. 29 Apr. 2016.";
        citeScreen.strAPA = @"Enerdata. (2016, April 22). India's crude oil imports rose 7% in 2015-16 as consumption grew by 11%. Retrieved April 29, 2016, from http://www.enerdata.net/enerdatauk/press-and-publication/energy-news-001/indias-crude-oil-imports-rose-7-2015-16-consumption-grew-11_36906.html";

        citeScreen.citeWhichTopic = @"energy";
    }
    else if ([statWhichTopic isEqualToString:@"gunControl"]) {
        citeScreen.strMLA = @"Fingerhut, Hannah. \"5 Facts about Guns in the United States.\" Pew Research Center- Fact Tank: News in the Numbers. Pew Research Center, 05 Jan. 2016. Web. 28 Apr. 2016.";
        citeScreen.strAPA = @"Fingerhut, H. (2016, January 05). 5 facts about guns in the United States. Retrieved April 28, 2016, from http://www.pewresearch.org/fact-tank/2016/01/05/5-facts-about-guns-in-the-united-states/";

        citeScreen.citeWhichTopic = @"gunControl";
    }
    else if ([statWhichTopic isEqualToString:@"internet"]) {
        citeScreen.strMLA = @"\"Internet Live Stats - Internet Usage & Social Media Statistics.\" Internet Live Stats - Internet Usage & Social Media Statistics. InternetLiveStats.com, n.d. Web. 21 Apr. 2016.";
        citeScreen.strAPA = @"InternetLiveStats.com. (n.d.). Internet Live Stats - Internet Usage & Social Media Statistics. Retrieved April 21, 2016, from http://www.internetlivestats.com/";

        citeScreen.citeWhichTopic = @"internet";
    }
    else if ([statWhichTopic isEqualToString:@"marijuana"]) {
        citeScreen.strMLA = @"\"Marijuana Stats.\" Caron. Caron Treatment Centers, 2016. Web. 30 Apr. 2016.";
        citeScreen.strAPA = @"Caron Treatment Centers. (2016). Marijuana Stats. Retrieved April 30, 2016, from http://www.caron.org/understanding-addiction/statistics-outcomes/marijuana-stats";

        citeScreen.citeWhichTopic = @"marijuana";
    }
    else if ([statWhichTopic isEqualToString:@"overpopulation"]) {
        citeScreen.strMLA = @"Hetzel, Lisa, and Annetta Smith. \"65 Years and Over Population: 2001.\" Google Books. Diane Publish Co., 2008. Web. 10 Apr. 2016.";
        citeScreen.strAPA = @"Hetzel, L., & Smith, A. (2008). 65 Years and Over Population: 2001. Retrieved April 10, 2016, from https://books.google.com/books?id=Gndl_pIhnZkC";

        citeScreen.citeWhichTopic = @"overpopulation";
    }
    else if ([statWhichTopic isEqualToString:@"police"]) {
        citeScreen.strMLA = @"USA.gov. \"Uniform Crime Reports- Detailed Assault Data.\" FBI- The Federal Bureau of Investigation. U.S. Government, U.S. Department of Justice, 2014. Web. 29 Apr. 2016.";
        citeScreen.strAPA = @"FBI. (2014). Uniform Crime Reports- Detailed Assault Data. Retrieved April 29, 2016, from https://www.fbi.gov/about-us/cjis/ucr/leoka/2014/detailed-assault-topic-page-summaries";

        citeScreen.citeWhichTopic = @"police";
    }
    else if ([statWhichTopic isEqualToString:@"pornography"]) {
        citeScreen.strMLA = @"\"Pornhub’s 2015 Year in Review.\" Pornhub Insights. Pornhub, 2016. Web. 19 Apr. 2016.";
        citeScreen.strAPA = @"\"Pornhub’s 2015 Year in Review.\" Pornhub Insights. Pornhub, 2016. Web. 19 Apr. 2016.";

        citeScreen.citeWhichTopic = @"pornography";
    }
    else if ([statWhichTopic isEqualToString:@"prison"]) {
        citeScreen.strMLA = @"Savage, Charlie. \"Justice Dept. Seeks to Curtail Stiff Drug Sentences.\" The New York Times. The New York Times, 11 Aug. 2013. Web. 20 Apr. 2016.";
        citeScreen.strAPA = @"Savage, C. (2013). Justice Dept. Seeks to Curtail Stiff Drug Sentences. Retrieved April 20, 2016, from http://www.nytimes.com/2013/08/12/us/justice-dept-seeks-to-curtail-stiff-drug-sentences.html?pagewanted=all";

        citeScreen.citeWhichTopic = @"prison";
    }
    else if ([statWhichTopic isEqualToString:@"rape"]) {
        citeScreen.strMLA = @"\"Facts & Quotes: Statistics.\" Rape Treatment Center | Santa Monica | UCLA Medical Center. Rape Treatment Center, n.d. Web. 18 Apr. 2016.";
        citeScreen.strAPA = @"Rape Treatment Center. (n.d.). Facts & Quotes: Statistics. Retrieved April 18, 2016, from http://www.911rape.org/facts-quotes/statistics";

        citeScreen.citeWhichTopic = @"rape";
    }
    else if ([statWhichTopic isEqualToString:@"religion"]) {
        citeScreen.strMLA = @"\"The Global Religious Landscape.\" Pew Research Center- Religion Public Life. Pew Research Center, 18 Dec. 2012. Web. 29 Apr. 2016.";
        citeScreen.strAPA = @"Pew Research Center. (2012, December 18). The Global Religious Landscape. Retrieved April 29, 2016, from http://www.pewforum.org/2012/12/18/global-religious-landscape-exec/";

        citeScreen.citeWhichTopic = @"religion";
    }
    else if ([statWhichTopic isEqualToString:@"robotics"]) {
        citeScreen.strMLA = @"\"Industrial Robot Statistics.\" Statistics- IFR International Federation of Robotics. IFR, 2015. Web. 26 Apr. 2016.";
        citeScreen.strAPA = @"IFR- International Federation of Robotics. (2015). Industrial Robot Statistics. Retrieved April 26, 2016, from http://www.ifr.org/industrial-robots/statistics/";

        citeScreen.citeWhichTopic = @"robotics";
    }
    else if ([statWhichTopic isEqualToString:@"socialMedia"]) {
        citeScreen.strMLA = @"Baer, Jay. \"11 Shocking New Social Media Statistics in America.\" Convince & Convert. Convince & Convert, LLC, 2008-2016. Web. 27 Apr. 2016.";
        citeScreen.strAPA = @"Baer, J. (2008-2016). 11 Shocking New Social Media Statistics in America. Retrieved April 27, 2016, from http://www.convinceandconvert.com/social-media-research/11-shocking-new-social-media-statistics-in-america/";

        citeScreen.citeWhichTopic = @"socialMedia";
    }
    else if ([statWhichTopic isEqualToString:@"sexuality"]) {
        citeScreen.strMLA = @"\"FAQ: Facts and Statistics.\" The Kinsey Institute - Sexuality Information Links - FAQ [Related Resources]. The Kinsey Institute/ Indiana University, 1996-2016. Web. 21 Apr. 2016.";
        citeScreen.strAPA = @"The Kinsey Institute/ Indiana University. (1996-2016). The Kinsey Institute - Sexuality Information Links - FAQ [Related Resources]. Retrieved April 21, 2016, from http://www.kinseyinstitute.org/resources/FAQ.html#resources";

        citeScreen.citeWhichTopic = @"sexuality";
    }
    else {
        citeScreen.strMLA = @"\"Falcon Heavy.\" SpaceX. Space Exploration Technologies Corp., 2016. Web. 26 Apr. 2016.";
        citeScreen.strAPA = @"Space Exploration Technologies Corp. (2016). Falcon Heavy. Retrieved April 26, 2016, from http://www.spacex.com/falcon-heavy";

        citeScreen.citeWhichTopic = @"spaceExploration";
    }
}

    else if ([statWhichTopic isEqualToString:@"religion"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"religion";
    }
    else if ([statWhichTopic isEqualToString:@"robotics"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"robotics";
    }
    else if ([statWhichTopic isEqualToString:@"socialMedia"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"socialMedia";
    }
    else if ([statWhichTopic isEqualToString:@"sexuality"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"sexuality";
    }
    else {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"spaceExploration";
    }
}
//stat8 data... COMPLETE
else {

    CiteViewController *citeScreen = [segue destinationViewController];

    citeScreen.citeWhichStat = @"8";

    if ([statWhichTopic isEqualToString:@"abortion"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

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

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

        citeScreen.citeWhichTopic = @"climateChange";
    }
    else if ([statWhichTopic isEqualToString:@"cybersecurity"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"cybersecurity";
    }
    else if ([statWhichTopic isEqualToString:@"discrimination"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"discrimination";
    }
    else if ([statWhichTopic isEqualToString:@"education"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"education";
    }
    else if ([statWhichTopic isEqualToString:@"energy"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"energy";
    }
    else if ([statWhichTopic isEqualToString:@"gunControl"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"gunControl";
    }
    else if ([statWhichTopic isEqualToString:@"internet"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"internet";
    }
    else if ([statWhichTopic isEqualToString:@"marijuana"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"marijuana";
    }
    else if ([statWhichTopic isEqualToString:@"overpopulation"]) {
        citeScreen.strMLA = @"Stancheva, Tina. \"Human Nature, Technology & the Environment.\" Human Nature, Technology & the Environment. 2003. Web. 10 Apr. 2016.";
        citeScreen.strAPA = @"Stancheva, T. (2003). Human Nature, Technology & the Environment. Retrieved April 10, 2016, from http://fubini.swarthmore.edu/~ENVS2/S2003/Tina/overpopulation";

        citeScreen.citeWhichTopic = @"overpopulation";
    }
    else if ([statWhichTopic isEqualToString:@"police"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"police";
    }
    else if ([statWhichTopic isEqualToString:@"pornography"]) {
        citeScreen.strMLA = @"\"Pornhub’s 2015 Year in Review.\" Pornhub Insights. Pornhub, 2016. Web. 19 Apr. 2016.";
        citeScreen.strAPA = @"\"Pornhub’s 2015 Year in Review.\" Pornhub Insights. Pornhub, 2016. Web. 19 Apr. 2016.";

        citeScreen.citeWhichTopic = @"pornography";
    }
    else if ([statWhichTopic isEqualToString:@"prison"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"prison";
    }
    else if ([statWhichTopic isEqualToString:@"rape"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"rape";
    }
    else if ([statWhichTopic isEqualToString:@"religion"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"religion";
    }
    else if ([statWhichTopic isEqualToString:@"robotics"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"robotics";
    }
    else if ([statWhichTopic isEqualToString:@"socialMedia"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"socialMedia";
    }
    else if ([statWhichTopic isEqualToString:@"sexuality"]) {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"sexuality";
    }
    else {
        citeScreen.strMLA = @"";
        citeScreen.strAPA = @"";

        citeScreen.citeWhichTopic = @"spaceExploration";
    }
}

} `

1
Since cybersecurity is your "fall through" case, anytime you don't get a matching segue name you will get cyber security. Double check your segue names carefully, set a breakpoint in prepareForSegue and step through to see what values you actually havePaulw11
I checked my segue identifiers three times and caught nothing. My breakpoint places an error immediately after the -(void) prepareForSegue... line where I call the method. This confuses me, what should I presume from this?user3884788
A breakpoint shouldn't cause an error. It should stop your app so that you can examine variables in the debugger and step line by line. Even printing your segue identifier may help if you can't figure out the debuggerPaulw11
Ah, true, I mixed up my terminology; no errors, just has the Thread 1: breakpoint 1.1 label as it should. My debugger reads self, sender, and segue with different objects listed under each downarrow. The breakpoint always appears on the line under -(void) prepareForSegue... Regarding printing my identifier: NSLogs do not even appear, as if the prepareForSegue method is not even being called.user3884788
That means you are no in the debugger. You can use the buttons to step line by line and examine your variables in the left hand view. The debugger is a very powerful tool. You should learn how to use itPaulw11

1 Answers

0
votes

An if statement cannot 'retain data from' an else statement. It just means that the condition in the if statement isn't being met so it is defaulting. I would recommend checking your spelling on the segue identifiers. Those in your code must match exactly to your storyboard. That's really the only thing I can think of if all the others work except for the Abortion statistics. If this doesn't work, try adding some NSLog statements to print the segue identifier and see why it isn't equal to "abortSeg".

In regard to your second question, I don't exactly understand what you are asking. Your app is crashing when you pop a view controller from the navigation stack? I'd need to see some code to figure out what is going wrong.