Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

plist problems

OK I've been trying to make a workable plist but when I create one, I begin with a dictionary that says Root. In the tutorial there is not one, it is blank. When I put any information in I don't get any item stuff back, I just get

" Application windows are expected to have a root view controller at the end of application launch'

This is getting annoying. Can anyone help me?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Which project template are you using? Either you need a storyboard or need to define a rootViewController in your AppDelegate.

3 Answers

no matter what template I use, it shows up.

I haven't written any new code for it. It just shows up as a default. This is what I see.

http://i.imgur.com/UyeEubP.jpg

Are there any other views that would be helpful?

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

We need to backtrack here. Are you having problems entering info into the plist? Or are you getting an error when running your application?

I'm not having any direct problems right now. I'm just concerned because sometimes my screen is set up slightly differently than what I see in the videos and sometimes it seems to cause problems. I was having errors originally but for some reason when I followed along with the video this time it worked. ces't la vie.

I'm wanting to create a quiz game that uses a plist as its source. I'm still struggling with the syntax and I'm just trying to mitigate potential issues further down the road.

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

There might be few differences due to the versions of Xcode. Those videos are over a year old and Xcode tends to do things differently with every new release. We are in the process of updating videos but that will take some time.

Glad to hear that you are building an app because that's the best way to learn! And struggling is part of the learning and developing process. So you are doing it right ;)

I've been following along on a bunch of youTube videos for quiz designs but I get an error when I try to go to the "play screen" and I get a breakpoint about my NSdictionary. my plist is named questions but I don't know if this whole "root" beginning business is what is causing the problem.

#import "PlayViewController.h"

@interface PlayViewController ()

@end

@implementation PlayViewController

@synthesize btnBack;
@synthesize lblQuestionTitle;
@synthesize lblAnswerA;
@synthesize lblAnswerB;
@synthesize lblAnswerC;
@synthesize lblAnswerD;
@synthesize btnA;
@synthesize btnB;
@synthesize btnC;
@synthesize btnD;

@synthesize questions = questions_;
@synthesize answer = answer_;



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    NSString *path = [[NSBundle mainBundle] pathForResource:@"Questions" ofType:@"plist"];
    NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:path];
    self.questions = [tempDict objectForKey:@"Questions"];

    NSDictionary *firstQuestion = [self.questions objectAtIndex:0];
    self.lblQuestionTitle.text = [[self.questions objectAtIndex:0] objectForKey:@"QuestionAnswer"];
    self.lblAnswerA.text = [firstQuestion objectForKey:@"A"];
    self.lblAnswerB.text = [firstQuestion objectForKey:@"B"];

    if ([firstQuestion objectForKey:@"C"]) {

        self.lblAnswerC.hidden = NO;
        self.btnC.hidden = NO;

        self.lblAnswerC.text = [firstQuestion objectForKey:@"C"];
    }
    else {
        self.lblAnswerC.hidden = YES;
        self.btnC.hidden = YES;
    }

    if ([firstQuestion objectForKey:@"D"]) {

        self.lblAnswerD.hidden = NO;
        self.btnD.hidden = NO;

        self.lblAnswerD.text = [firstQuestion objectForKey:@"D"];
    }
    else {
        self.lblAnswerD.hidden = YES;
        self.btnD.hidden = YES;
    }

    }

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

I would put NSLogs or add a breakpoint at the first line of viewDidLoad and step through the execution of your code. It might be that you are assuming that self.questions is an array and it is actually a dictionary or that [self.questions objectAtIndex:0] results in an array and you are assuming that it is a dictionary. Like I said add NSlogs and step through your code to see where it is crashing and if your assumptions are right.