I have a method that gets the IBOutlet of another class by initializing an instance to the other class and then runs code that uses the references to the IBOutlets to set a memory address in another app. The code runs fine but is periodically updated by a timer that I set up to refresh every 5 seconds. The problem is that every 5 seconds the memory address is periodically changed to the wrong value and then back to the right value. Here is my essential code:
#define OFF 0
#define ON 1
- (void)onOff:(id)sender {
if ([[appDelegate buttonOutletName] state] == ON) {
[helper setIntForAddress:0xFFFFFF value:1];
}
if ([[appDelegate buttonOutletName] state] == OFF) {
[helper setIntForAddress:0xFFFFFF value:0];
}
}
The problem is that whenever I call this code from anything other than a button press (ex. [self onOff:self]; ) It briefly sets the value to 0 and then back to 1. My code worked fine when implemented inside the application controller; however, now it works but with this error. If anyone could help me that would be greatly appreciated. Thanks.
I imagine the method is somehow being called twice. Are you sure you're only calling it once? Check with the Instruments app to see if it is indeed being called twice.