I am constantly getting the EXC_BAD_ACCESS error in multiple places but always on the nsuserdefaults below is the places were it keeps erroring.
//Get results
NSString *currentYes = [[NSUserDefaults standardUserDefaults] stringForKey:@"yes"];
NSString *currentNo = [[NSUserDefaults standardUserDefaults] stringForKey:@"no"];
And again here:
- (IBAction)VoteQ1:(id)sender
{
//Save question 1 to device
[[NSUserDefaults standardUserDefaults] setObject:@"Q1" forKey:@"questionnumber"];
[[NSUserDefaults standardUserDefaults] setObject:[self.Question1 objectAtIndex:0] forKey:@"Question"];
[[NSUserDefaults standardUserDefaults] setObject:[self.Question1 objectAtIndex:1] forKey:@"yes"];
[[NSUserDefaults standardUserDefaults] setObject:[self.Question1 objectAtIndex:2]forKey:@"no"];
[[NSUserDefaults standardUserDefaults] setObject:[self.Question1 objectAtIndex:3] forKey:@"start"];
[[NSUserDefaults standardUserDefaults] setObject:[self.Question1 objectAtIndex:4] forKey:@"end"];
[[NSUserDefaults standardUserDefaults] synchronize];
FlipViewController *controller = [[FlipViewController alloc] initWithNibName:@"FlipView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
i also have (IBAction)VoteQ2:(id)sender and (IBAction)VoteQ3:(id)sender which are the same as above but self.question1 is like question 2 or 3.
The error comes when i click another ibaction after clicking and completing the flip view.
Please help i believe it is something to do with nsuserdefaults not releasing it self
Thanks
It might be a casting problem. You are setting an object
but fetching it into an NSString:
Assuming your objects in Question1 array are NSString objects, try this: