NSInteger total = 4556; // Initialize total
// NSLog all fields to make sure the variables are in place
NSLog(@"%@", originField.text);
NSLog(@"%@", destinationField.text);
NSLog(@"%i", [startField.text integerValue]);
NSLog(@"%i", [endField.text integerValue]);
NSLog(@"%i", total);
// Create a dictionary of them
NSDictionary *newDict = [[NSDictionary alloc] initWithObjectsAndKeys:@"Sat. Jan 6th, 2014", @"date", originField.text, @"origin", destinationField.text, @"destination", [startField.text integerValue], @"start", [endField.text integerValue], @"end", total, @"total", @"Personal", @"type", nil];
// EXC_BAD_ACCESS CODE 1
I've tried using the Zombies template in Instruments, but I never get a dialog. When breakpointing, the app crashes on the initWithObjectsAndKeys. Where are my dead variable(s)?
You can not put primitive types into Dictionary. Wrap the variable total with NSNumber
and then put it into Dictionary.
NSDictionary *newDict = [[NSDictionary alloc] initWithObjectsAndKeys:@"Sat. Jan 6th, 2014", @"date",
originField.text, @"origin",
destinationField.text, @"destination",
@([startField.text integerValue]), @"start",
@([endField.text integerValue]), @"end",
@(total), @"total",
@"Personal", @"type", nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With