Here is my code:
.h
@interface AppDelegate : NSObject <NSApplicationDelegate>{
NSString *lastValue;
}
.m
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
lastValue = nil;
}
- (void) fullDMXReceived:(NSString*)finalData {
if (finalData != lastValue) {
lastValue = finalData;
// doing something
}
}
For some reason, ‘doing something’ is only called once, and it stops.
Some background info: ‘fullDMXReceived’ is called every 100 miliseconds or so with new information. Sometimes (many times actually) the data is the same, and thus, I do not want ‘doing something’ to run. If it’s different, I DO want ‘doing something’ to happen.
I’m not sure why it’s only running ‘doing something’ once even when the finalData changes.
Any ideas?
If
bufferinfullDMXReceived:is aNSMutableStringinstance that is reused you will need to copy the actual string instead of just assign the instance, try something like this: