Objective-C Loop Through NSMutableArray?
Very simple question - how might I iterate through a NSMutableArray and do things for each item?
开发者_Python百科Much like the for loop in other langs:
foreach(array)
{
dosomething();
}
If you want to call a method in each one, use
[array makeObjectsPerformSelector:@selector(eatFish)];
or if you want to pass an argument,
[array makeObjectsPerformSelector:@selector(eat:) withObject:myFishObject];
精彩评论