概述
关于NSEnumerator
从iOS 2.0开始,可以使用NSEnumerator来枚举NSArray、NSDictionary和NSSet对象中的元素。NSEnumerator本身是个抽象类。它依靠几个工厂方法,如objectEnumerator或keyEnumerator,来创建并返回相应的具体枚举器对象。客户端用返回的枚举器对象遍历集合中的元素,如下面的代码段所示。
2016-08-10 18:27:37.573 CollectionViewDemo[1161:151734] {
"headline_ad" = (
{
imgsrc = "http://cms-bucket.nosdn.127.net/34a3d631fede42678a437decbd2be06320160810170353.jpeg";
subtitle = "";
tag = photoset;
title = "U91ccU7ea6U4e00U5965U8fd0U5a92U4f53U5927U5df4U906dU88adU51fb U81f4U8bb0U8005U53d7U4f24";
url = "00AO0001|2190986";
},
{
imgsrc = "http://cms-bucket.nosdn.127.net/fce0a63fbd344839ae18ce3cad0c61b220160810154706.jpeg";
subtitle = "";
tag = photoset;
title = "U63a2U8bbfU5df4U897fU70edU5e26U96e8U6797U6df1U5904U7684U907fU5b55U5957U5de5U5382";
url = "57KT0001|2190981";
},
{
imgsrc = "http://cms-bucket.nosdn.127.net/c722897a9e6346f48966482eb85f411620160810144048.jpeg";
subtitle = "";
tag = photoset;
title = "U5185U8499U53e4U73b0U5f3aU964dU6c34 U653fU5e9cU5927U697cU906dU6d2aU6c34"U6d17U52ab"";
url = "00AP0001|2190979";
},
{
imgsrc = "http://cms-bucket.nosdn.127.net/88a4272be3ce43f7ab778c64fc7ed86620160810094032.jpeg";
subtitle = "";
tag = photoset;
title = "U6e38U5ba2U591cU6e38U5927U8fdeU6d77U8fb9 U7559U4e0bU5783U573eU904dU5730";
url = "00AP0001|2190941";
}
);
}
下面我们来取出数据.
NSString *urlString = @"http://c.m.163.com/nc/ad/headline/0-4.html";
[[HYFNetworkTools sharedTools]requsetWithType:GET urlString:urlString params:nil success:^(NSDictionary * response) {
//取出字典中的第一个元素.
NSString *rootKey = response.keyEnumerator.nextObject;
NSArray *array = response[rootKey];
NSMutableArray *mArray = [NSMutableArray array];
[array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
HYFHeadLineModel *model = [HYFHeadLineModel modelWithDict:obj];
[mArray addObject:model];
}];
successBlock(mArray.copy);
} failure:^(NSError *error) {
failureBlock(error);
}];
最后
以上就是机智大米为你收集整理的关于NSEnumerator关于NSEnumerator的全部内容,希望文章能够帮你解决关于NSEnumerator关于NSEnumerator所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复