I wanted the app to ask a question the first time, and ONLY the first time the app was ran, so in the AppDelegate didFinishLaunchingWithOptions I have:
Then I have in the AppDelegate Still:
I wanted these values to be changed in a Settings window, so in the Settings class I have:
The line that the crash log says is causing the crash is:
I'm assuming it has something to do with the notFirstRun Bool in AppDelegate, but can't get my finger on it. What do you think the issue may be?
Code:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (! [defaults boolForKey:@"notFirstRun"]) {
UIAlertView *firstrun = [[UIAlertView alloc] initWithTitle:@"Sermon Preference" message:@"Do you prefer audio only, or video sermons? (This setting can be changed at any time in the Settings Page.)" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Audio", @"Video", nil];
[firstrun show];
[firstrun release];
[defaults setBool:YES forKey:@"notFirstRun"];
}
Code:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *nope = @"Audio";
[defaults setObject:nope forKey:@"videosermons"];
[defaults synchronize];
}
if (buttonIndex == 1) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *yup = @"Video";
[defaults setObject:yup forKey:@"videosermons"];
[defaults synchronize]; }
}
Code:
- (void)viewDidLoad
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *currently = [defaults objectForKey:@"videosermons"];
if ([currently isEqualToString:@"Audio"]) {
segment.selectedSegmentIndex = 0;
}
if ([currently isEqualToString:@"Video"]) {
segment.selectedSegmentIndex = 1;
}
NSString *firstName = [defaults objectForKey:@"firstName"];
if (firstName == nil) {
}
else {
myTextField.text = firstName;
}
NSURL *url = [NSURL URLWithString:@"http://www.bellavenue.org/worship.html"];
self.content = [NSString stringWithContentsOfURL:url];
[super viewDidLoad];
}
Code:
if ([currently isEqualToString:@"Audio"]) {
Last edited: