I actually wrote a method which switches some UIViews. When I enter the method I have to know which is my current view to remove exactly this one from the superview. I declared a property for this purpose in the header file:
@property (weak, nonatomic) UIView *currentView;
After I changed to a certain view in my method, I want to assign this view to the property in order to use it when I enter the method again and remove this view from the superview if requested. The method looks like this:
...
nextView = [self loadNextView]; // the view is loaded from a NIB here
if (self)
{
[self viewWillDisappear:YES];
[[self currentView] removeFromSuperview];
[[self view] addSubview:nextView];
[self currentView] = [self nextView];
...
Unfortunately the compiler tells me that currentView is not assignable here. Is there another, hopefully better, way to remeber the curernt view for my purpose or should I use a completely different way?
Instead of the following line,
do as follows: