Use instance variable for tracking if a target was added to ASControlNode

This commit is contained in:
Michael Schneider
2016-02-02 08:30:52 -08:00
parent ddf50b20bd
commit 12e2b535db
2 changed files with 3 additions and 10 deletions

View File

@@ -19,12 +19,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface ASControlNode (Subclassing)
/**
@abstract Indicates whether or not at least one target was added to the receiver
@discussion YES if the receiver has at least one target; NO otherwise.
*/
@property (nonatomic, readonly, assign, getter=isTargetAdded) BOOL targetAdded;
/**
@abstract Sends action messages for the given control events.
@param controlEvents A bitmask whose set flags specify the control events for which action messages are sent. See "Control Events" in ASControlNode.h for bitmask constants.

View File

@@ -48,7 +48,6 @@
}
// Read-write overrides.
@property (nonatomic, readwrite, assign, getter=isTargetAdded) BOOL targetAdded;
@property (nonatomic, readwrite, assign, getter=isTracking) BOOL tracking;
@property (nonatomic, readwrite, assign, getter=isTouchInside) BOOL touchInside;
@@ -89,14 +88,14 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v
[super didLoad];
// As we have no targets yet, we start off with user interaction off. When a target is added, it'll get turned back on.
if (!self.targetAdded) {
if (!_targetAdded) {
self.userInteractionEnabled = NO;
}
}
- (BOOL)shouldTrackTouches
{
return self.isTargetAdded && self.enabled;
return _targetAdded && self.enabled;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -270,7 +269,7 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v
[targetActions addObject:NSStringFromSelector(action)];
});
self.targetAdded = YES;
_targetAdded = YES;
self.userInteractionEnabled = YES;
}