I am adding a XIB as a subview just for a temporary use. It is full screen and I think my code below is inefficient. I know I am doing something wrong here. My subview is getting weird crashes and warning messages in the console. I know there is nothing wrong with the code in the subview because I have tested it before differently.
Am I doing something wrong here?
self.sp = [[Score alloc] initWithNibName:@"Score" bundle:nil];
[self.view addSubview:self.sp.view];
[self.sp.view setFrame:CGRectMake(0, 485, 320, 480)];
[self.sp.view setBackgroundColor:[UIColor clearColor]];
[UIView animateWithDuration:1
delay:0
options:UIViewAnimationOptionCurveLinear
animations:^{
[self.sp.view setCenter:self.view.center];
}
completion:nil];
I think it has something to do with the releasing of ‘sp’ in my case. How would I release it properly? I am dismissing the view in its view controller and not in this view.
Thanks!
You most certainly are leaking
Scoreobjects.When you
allocinitan object, it returns an object with a retain count of 1, which you are neverreleaseing. Even more, if yourspproperty is aretainproperty, you’ll further increase the retain count by one, and again, you need to balance that with areleasecall.Assuming
spis aretainproperty, try the following:and make sure your
deallocmethod is alsoreleaseingsp.