Keeping object in memory (iPhone SDK)
Posted
by Chris
on Stack Overflow
See other posts from Stack Overflow
or by Chris
Published on 2010-05-21T04:59:31Z
Indexed on
2010/05/21
5:30 UTC
Read the original article
Hit count: 158
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?
- (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);
...
}
© Stack Overflow or respective owner