in my iOS app’s viewDidLoad method, i have the following line of code:
loadDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"1.0", "version number", nil];
and it causes an EXC_BAD_ACCESS error. i don’t know why. nothing else in the viewDidLoad method uses the object except the other side of the if/else statement this line is in, so there’s no way it could have been released already. i’m just not sure what the problem is. if you want to see my whole viewDidLoad method, here it is:
- (void)viewDidLoad
{
[super viewDidLoad];
tapsBackground = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
tapsBackground.delegate = self;
[self.view addGestureRecognizer:tapsBackground];
saveChangesButton.hidden = YES;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
filePath = [documentsDirectory stringByAppendingPathComponent:@"presets.plist"];
if([[NSFileManager defaultManager] fileExistsAtPath:filePath]){
loadDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
}
else{
loadDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"1.0", "version number", nil];
[loadDict writeToFile:filePath atomically:YES];
}
}
The problem is that you are missing
@in the second string i.e."version number".It should be,