ios之快速枚举
来源:互联网 发布:天猫红包怎么领取淘宝 编辑:程序博客网 时间:2024/05/22 04:25
另外,OC中有一个专门的快速枚举的迭代器类NSEnumerator,这个类的使用方法如下:
for(UIView * subView in self.view.subviews)
{
if([subView isKindOfClass:[XYZSeniorQueryView class]])
{
[subView removeFromSuperview];
subView = nil;//错误
}
}
错误提示信息:
Fast enumeration variables can't be modified in ARC by default;declare the variable __strong to allow this
也就是说:
快速枚举变量在ARC下默认不能修改其引用属性,声明变量为__strong允许这样。
按照提示修改上面的语句:
for(__strong UIView * subView in self.view.subviews)
或者
for(UIView __strong * subView in self.view.subviews)
这样就可以正常运行了。
//得到一个对应的enumerator对象
NSEnumerator * enumerator = [self.view.subviews reverseObjectEnumerator];
for(UIView * views = [enumerator nextObject];;)//遍历
{
if([views isKindOfClass:[XYZSeniorQueryView class]])
{
[views removeFromSuperview];
views = nil;
}
}
- ios之快速枚举
- [iOS/OC]快速枚举enumerateObjectsUsingBlock
- iOS之枚举用法
- iOS开发之CLAuthorizationStatus枚举
- Swift快速入门之枚举与结构
- c++之枚举 快速入门及使用
- 快速枚举
- 快速枚举
- 快速枚举
- 快速枚举
- 快速枚举
- 快速枚举
- 快速枚举
- IOS之路-枚举遍历的方式
- iOS讲解迷惑之typedef枚举
- iOS——之数组 字典 枚举
- 快速枚举 快速遍历
- 【IOS】IOS快速入门之OC语法
- ASIHTTPRequest的使用方法
- iOS设计模式---MVC
- iOS设计模式---委托
- 解析器模式
- iOS设计模式---单例模式
- ios之快速枚举
- 把UITextField等控件加到UITollBar上面
- UIImageView之userInteractionEnabled 属性
- Objective-C之@encode关键字
- Objective-C语法之动态类型常用方法总结
- 用代码分割一张图片的方法
- IOS面试攻略(1.0)
- ios面试攻略(1.1)
- Oracle自增ID实现