I am new to iOS. I am trying to set a bool in a view controller in the prepareforsegue method that leads to that view controller. When I try to to set the bool, i get an EXC_BAD_ACCESS error. What can I do to fix this problem?
addBookViewController *addViewController = [segue destinationViewController];
Book *temp = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];
addViewController.book = temp;
*addViewController.editMode=YES; //EXC_BAD_ACCESS (Code =0, address=0x0)
here is the header file for the destination view controller:
@interface addBookViewController : UITableViewController <UITextFieldDelegate>
@property (strong, nonatomic) Book *book;
@property (assign) BOOL *editMode;
@end
BOOLis not an object type, it’s a primitive (scalar). You don’t need pointers to it. Changeinto
and also change
to
and please read a tutorial on C pointers.