转换为Objective-C中的快速枚举

时间:2013-06-18 11:01:31

标签: objective-c performance nsarray enumeration

我有这个传统的for循环,我想转换为快速枚举。我怎样才能做到这一点?谢谢!

for (int i = 0; i < [_objects count]; i++)
{
    schedule = [[JSSchedule alloc] initWithDictionary:_objects[i]];
}

2 个答案:

答案 0 :(得分:3)

使用此

for(NSDictionary *object in _objects)
{
    schedule = [[JSSchedule alloc] initWithDictionary: object];
}

答案 1 :(得分:0)

像这样:

for (id object in _objects)
{
    schedule = [[JSSchedule alloc] initWithDictionary: object];
}