I am creating an app where when you touch a pimple it moves to a different location. This is the code that I put:
pimple.location = (320, 64);
(I have created an IBOutlet for pimple and connected it)
I get the following error:
request for member ‘location’ in something not a structure or union
Here is my .m code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint point = [myTouch locationInView:pimple];
if ( CGRectContainsPoint(pimple.bounds, point) ) {
[self checkcollision];
}
}
-(void)checkcollision {
label.text += 1;
pimple.hidden = YES;
pimple.location = (320, 64); //the error
sad.hidden = NO;
NSURL* popURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"pop" ofType:@"mp3"]];
AudioServicesCreateSystemSoundID((CFURLRef) popURL, &popID);
AudioServicesPlaySystemSound(popID);
}
The location property is (probably) of type
CGPoint(a struct), you can’t just assign a point value by providing two numbers. You would typically assign it with the helper functionCGPointMake:or: