I have a custom subclass of UIView that needs to perform a selector when a value (NSInteger) falls below a certain value. From what I can tell from the docs, I need to set up an observer object to look for this change.
The NSInteger value exists in the view controller and the UIView subclass is implemented as a subview in the same view controller.
I wondering if something like the following is on the right track:
-(void)createNotification:
[[NSNotificationCenter defaultCenter]
addObserver:self //since this is in the viewController, I'm thinking it's "self"
selector:@selector(genCountLow:)
name:@"ReviewGenCount"
object: nil ];
I'm struggling with where I would add the condition for this observer to perform the action. For instance, if the condition would be:
if(genCount < 3) {
///code statement
}
I want my observer to look for the above change and then perform a subsequent action. Would I add that to my notification object like this?
- (void)genCountLow:(NSNotification *)notification {
if (genCount < 3) {
[electricalSystemDiagramView depowerShedBuses];
}
}