开发者

Objective-C Loop Through NSMutableArray?

开发者 https://www.devze.com 2023-01-13 01:06 出处:网络
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:

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消