In my project, I've declared a BOOL *isOn in my FirstViewController. In FirstViewController, I have two buttons where pressing buttonOne, sets isOn to YES, and buttonTwo sets isOn to NO. In my SecondViewController, I'm trying to run an if-statement that references the status of isOn. I'm getting error "Assigning to 'readonly' return result of an Objective-C not allowed". How may I get my desired intent?
//FirstViewController.h
@property (assign) BOOL isOn;
- (IBAction)buttonOne:(id)sender;
- (IBAction)buttonTwo:(id)sender;
//FirstViewController.m
- (IBAction)buttonOne:(id)sender {
[self setIsOn:YES];
}
- (IBAction)offSiteButton:(id)sender {
[self setIsOn:NO];
}
//SecondViewController.m
#import "FirstViewController.h"
#import "FirstViewController.m"
FirstViewController *FVC
- (void)viewDidLoad {
if ([FVC isOn] = YES) { <----Error
// Do this
} else {
// Do that
}
If I just run it with...
if ([FVS isOn])
The if-statement returns the else function and 'does that' for both buttons. Please help.