Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
I can include a zip of my actual project, I will PM you the link.

I may not get a chance to look at the code until tomorrow but I'll leave you with what I suspect your issue is: you think your init is getting called (and thus your questions array is populated), but it's not.
 
I may not get a chance to look at the code until tomorrow but I'll leave you with what I suspect your issue is: you think your init is getting called (and thus your questions array is populated), but it's not.

That's ok, I don't know why the array wouldn't be populated if in the zip file app you tried does it the same way as my code. The only thing I omitted in my source from the book example is having this
Code:
@interface QuizAppDelegate : NSObject <UIApplicationDelegate>

Where mine is:
Code:
@interface Questions :   UIViewController

Is that the problem? IE meaning excluding NSObject?
 
Solved!!

Hey guys, I just solved the code! What I did was this, I had to put the (id) within the viewDidLoad method! :cool:

Code:
#import "Questions.h"


@implementation Questions

@dynamic view;

- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
	return (interfaceOrientation !=
			UIInterfaceOrientationPortraitUpsideDown);
}

- (void)viewDidLoad { 
	
	[super viewDidLoad];
	self.title = @"Interview Questions"; 

	

	// Call the init method implemented by the superclass
	
	
	// Create questions array and make the pointers point to it
	questions = [[NSMutableArray alloc] init];
	
	
	// Add questions to the array
	[questions addObject:@"Where do you think our country lacks?"];
	
	
	[questions addObject:@"Who do you feel is the most popular person in the world? Why?"];
	
	
	[questions addObject:@"Should the government bail out failing companies?"];
	
	
	[questions addObject:@"Do you think someone's age should be a determining factor whether they are hired for a job or not?"];
	
	
	
	// Return the address of the new object
	return;
	
}

- (IBAction)showQuestion:(id)sender
{
	// Step to the next question - just to keep things simple
	// to focus on the iOS elements of the programming,
	// we will start with the "second" question in the list.
	currentQuestionIndex++;
	
	// Am I past the last question?
	if (currentQuestionIndex == [questions count]) {
		// Go back to the first question
		currentQuestionIndex = 0;
	}
	
	// Get the string at that index in the questions array
	NSString *question = [questions objectAtIndex:currentQuestionIndex];
	
	// Log the string to the console
	NSLog(@"displaying question: %@", question);
	
	//Display the string in the question field
	[questionField setText:question];
	
	
	
}



- (void)dealloc {
	
    [super dealloc];
}


@end
 
Last edited:
So, you moved the array population into the viewDidLoad. Good idea. Don't forget to be a good memory-citizen and release your array (often done in the dealloc, but would probably make more sense in the viewDidUnload, since that viewDidLoad's "opposite" method). Also, you should probably clean up some of the unnecessary comments and the return, so they don't cause confusion later.
 
So, you moved the array population into the viewDidLoad. Good idea. Don't forget to be a good memory-citizen and release your array (often done in the dealloc, but would probably make more sense in the viewDidUnload, since that viewDidLoad's "opposite" method). Also, you should probably clean up some of the unnecessary comments and the return, so they don't cause confusion later.

Will do!

Now how would I go about loading the 1st question into the UILabel upon initializing? Instead of having to have a placeholder text in the label saying "Push next question" I want it to have the first question if that makes any sense?
 
Now how would I go about loading the 1st question into the UILabel upon initializing? Instead of having to have a placeholder text in the label saying "Push next question" I want it to have the first question if that makes any sense?
Look at the code you already added. Do you already have a method that does pretty much what you're asking for here?
 
Look at the code you already added. Do you already have a method that does pretty much what you're asking for here?

I feel really stupid... Instead all I did was change the placeholder text to a different question, creating the illusion.
 
I feel really stupid... Instead all I did was change the placeholder text to a different question, creating the illusion.
Sounds like more of a band-aid than a solution. What happens if the text of that question changes? Now you'll need to change it in two places. I would suggest seeking a better solution that actually takes advantage of some of the customized code you've already written.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.