i am a beginner with ios programming, my project set it autorelease, and now i get a problem with autorelease function. i show my code and hope you can suport me to avoid this
- (void)initPhotoImage
{
photoImage = [[MyPhotoImageView alloc] initWithFrame:CGRectMake(5, 30, 0, 0)];
photoImage.photoViewController = self;
[photoView addSubview:photoImage];
UISwipeGestureRecognizer *gesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeLeft:)];
gesture.direction = UISwipeGestureRecognizerDirectionLeft;
[photoView addGestureRecognizer:gesture];
UISwipeGestureRecognizer *gesture1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
gesture1.direction = UISwipeGestureRecognizerDirectionRight;
[photoView addGestureRecognizer:gesture1];
}
-(void)didSwipeLeft:(UIGestureRecognizer *)gestureRecognizer {
if(self.nextViewController != NULL){
[UIView animateWithDuration:1 animations:^{
self.view.frame = CGRectMake(-1*self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height);
}];
NSLog(@"next");
}else{
NSLog(@"next view is null");
}
}
this 2 functions in a same class, i print self.nextViewController in the init function, it print a address but in swip function, i print self.nextViewController again but it print null address, in .h file i defined it retain
@property (retain, nonatomic) MyPhotoViewController *nextViewController;