Hi.. i am new to iPhone Programming. In my app i have HomeViewController and ContentViewController. i am saving the values in ContentViewController by using NSUserDefaults and based on saved values i will load the ContentView instead of HomeView when the app is restarted. if there r no values in the NSUserDefautls it displays the HomeView.
in HomeView i have some buttons..its like this.. each button is for a book so in contentView all the page nos (in the bottom in a scroll view in ContentView) will be displayed if i click on a page no it displays the text in the above label of ContentView.if the user closes the app in contentView, the page no and book no will be saved...if the user clicks on home button all the information will be deleted. In the Homeview im checking the NSUserDefaults , if it contains values it should display that exact page of that book the following is the code...
//HomeViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
contentViewController = [[ContentViewController alloc] initWithNibName:@"ContentView" bundle:nil];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSLog(@"...%d,%d,%d",[prefs integerForKey:@"Stage"],[prefs integerForKey:@"Stimulus"],[prefs integerForKey:@"Card"]);
if(!([prefs integerForKey:@"Stage"] ==0 && [prefs integerForKey:@"Stimulus"] ==0 && [prefs integerForKey:@"Card"] ==0)){
[contentViewController setCurrentState:[prefs integerForKey:@"Stage"]];
[contentViewController setCurrentStimulus:[prefs integerForKey:@"Stimulus"]];
[contentViewController setCurrentCard:[prefs integerForKey:@"Card"]];
[self presentModalViewController:contentViewController animated:YES];
}
}
but its displaying the homeview...
can anybody help me out please.......