I am trying to create a UIImageView called theImageView in the touchesBegan method that I can then then move to a new location in touchesMoved. Currently I am receiving an "undeclared" error in touchesMoved where I set the new location for theImageView.
What can I do to keep theImageView in memory between these two methods?
EDIT: I am unable to declare theImageView in the @interface as I need to create an image every time a certain point is touched.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
...
UIImageView *theImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
theImageView.frame = CGRectMake(263, 228, 193, 300);
[theImageView retain];
...
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
...
theImageView.frame = CGRectMake(300, 300, 193, 300);
...
}