Quick enumeration of iOS

Source: Internet
Author: User

For(UIView * subView . View. Subviews)

{

if([subView iskindofclass: [xyzseniorqueryview class]] )

{

[SubView removefromsuperview];

SubView = nil; error

}

}

Error message:

Fast Enumeration variables can ' t be modified on ARC by default;declare the variable __strong to allow THIS

Other words:

The Fast enumeration variable under ARC cannot modify its Reference property by default , declaring that the variable is __strong allowed.

Follow the prompts to modify the above statement:

for(__strong UIView * subView on self. View. Subviews)

or

for(UIView __strong * subView on self. View. Subviews)

This will work as expected.

In addition, there is a special fast-enumerating iterator class Nsenumerator in OC, which is used in the following way:

// get a corresponding enumerator object

Nsenumerator * Enumerator = [self.view.subviews reverseobjectenumerator];

For (UIView * views = [enumerator nextobject];;) // traversal

{

if ([Views Iskindofclass:[xyzseniorqueryview class]])

{

[Views Removefromsuperview];

views = nil;

}

}

Ext.: http://lqcjdx.blog.163.com/blog/static/20748924120139501547298/

Quick enumeration of iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.