In following line I get the warning “expected identifier before ‘[‘ token”
gestureRecognizer.[pictureElement piece].transform =
CGAffineTransformScale(gestureRecognizer.[pictureElement
piece].transform, gestureRecognizer.scale, gestureRecognizer.scale);
I guess it is a stupid mistake but I am sitting here for hours not finding the problem.
In the following you see the whole method
- (IBAction)pinchDetected:(UIPinchGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan || gestureRecognizer.state == UIGestureRecognizerStateChanged)
{
gestureRecognizer.[pictureElement piece].transform = CGAffineTransformScale(gestureRecognizer.[pictureElement piece].transform, gestureRecognizer.scale, gestureRecognizer.scale);
[gestureRecognizer setScale:1];
}
}
UPDATE
If I forgot to add a bracket, it would be more than one warning.
2nd Update
pictureElement is a class and piece is the attribute of the class.
So I want the Gesture react on the attribute piece of my class pictureElement.
PictureElement inherits from UIView and piece is a instance of UIView
3rd Update
I think there is nothing wrong in my gestures, because if I add self.view instead of [pictureElement piece] my screen starts to move and to react on my gestures
Thank you in advance
The
gestureRecognizer.[pictureElement piece].transform =doesn’t make sense. Things of the formx.y = z, wherexis an object instance, translate into[x setY:z]or something very similar at compile time — i.e. a messagesetY:zis sent to instancex.Not sure exactly what you’re trying to do, but is the case that the
gestureRecognizer.part is spurious and shouldn’t be there? The following code would perhaps make more sense (although wouldn’t necessarily be correct):As a side note on style matters, consider sticking consistently to either dot notation (
x.y) or message-passing notation ([x y]) in any one place when you’re dealing purely with properties. For example, instead of writing:you could stick to all dot notation, like so:
or you could make it all message-passing format, like so: