Q:

How to detect if sprite is being touched?

I'm trying to figure out how to know if the user is touching an sprite.
I simplified my code to the bare bones, on init I create a single sprite called "button" and then I try to know when the user is touching it/stops touching. 
This is what I'm trying now:
-(id)initWithSize:(CGSize)size {    
    if (self = [super initWithSize:size]) {
        self.backgroundColor = [SKColor colorWithRed:0 green:0 blue:0 alpha:1.0];

        // Add button
        SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"button"];
        sprite.name = @"button";
        sprite.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
        [self addChild:sprite];
    }
    return self;
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];
    SKNode *node = [self nodeAtPoint:location];
    if ([node.name isEqualToString:@"button"]) {
        NSLog(@"Started touch on sprite");
    }
}

-(void)update:(CFTimeInterval)currentTime {
/* Called before each frame is rendered */
}

However though I can tell if a touch starts on the button, I cannot tell if the user ends the touch or moves out of the sprite (or vicebersa). How can I do this?

A:

Add to properties: (allows you to access them in various methods)
@property (nonatomic) BOOL touchInSprite;
@property (nonatomic) SKSpriteNode * sprite;
@end

Add methods:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch * touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];

    if ([self.sprite containsPoint: location])                
        self.touchInSprite = true;      
    else
        self.touchInSprite = false;
}

 - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch * touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];

    if ([self.sprite containsPoint: location]) 
    {               
        self.touchInSprite = true;  
    }    
    else
    {
        self.touchInSprite = false;
        //user stop touches it
    }
}

 - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch * touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];

    if (self.startTouchValid == true)                
    {
    //Perform action
    }    
}

