Today, when you write a program, you want to release some of the sub-views of add on the current view when the current view jumps. Because some of the child views of add are added in other classes, the current page does not know what types of sub-views you currently have. In this way, I thought of looping through the history to see whether the current view has a sub-view of the qualifying, if any, release.
That's what I wrote:
For (UIView * SubView in Self.view.subviews) {
if ([SubView Iskindofclass:[xyzseniorqueryview class]]) {
[SubView Removefromsuperview]; SubView = nil;//Error
}
}
Error message: Fast enumeration variables can ' t is modified in ARC by default;declare the variable __strong
That is, the fast enumeration variable cannot modify its Reference property by default under Arc, declaring that the variable is __strong allowed.
Follow the prompts to modify the above statement:
for (__strong UIView * SubView in Self.view.subviews)
Or
for (UIView __strong * SubView in Self.view.subviews)
This will work as expected.
In addition, OC has a specialized fast enumeration iterator class Nsenumerator,
This class is used in the following way://Get a corresponding enumerator object
Nsenumerator * Enumerator = [self.view.subviews reverseobjectenumerator];
for (UIView * views = [Enumerator nextobject];;) Traverse
if ([Views Iskindofclass:[xyzseniorqueryview class]]) {
[Views Removefromsuperview]; views = nil;
}
}
6. iOS Quick Enumeration