Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNeil Bobenhouse
1,184 Pointsplist 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?
3 Answers
Neil Bobenhouse
1,184 Pointsno matter what template I use, it shows up.
Amit Bijlani
Treehouse Guest TeacherCan you share your code?
Neil Bobenhouse
1,184 PointsI 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
Treehouse Guest TeacherWe need to backtrack here. Are you having problems entering info into the plist? Or are you getting an error when running your application?
Neil Bobenhouse
1,184 PointsI'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
Treehouse Guest TeacherThere 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 ;)
Neil Bobenhouse
1,184 PointsI'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
Treehouse Guest TeacherI 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.
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherWhich project template are you using? Either you need a storyboard or need to define a
rootViewController
in yourAppDelegate
.