0
我創建功能,但我無法弄清楚如何確保每一個對象完成功能對象的數量創造了創建的對象
-(id) init{
if (self = [super init]){
_die = [[NSMutableArray alloc] init];
}
return self;
}
-(void) addDice:(Die *)d{
[_die addObject:d];
}
-(void) roll{
for (int i=0; i<_die; i++) //this is the part i don't get how to do'
{
Die *d = _die[i];
[d roll];
};
}
或者你也可以你的枚舉或快速枚舉:'for(Die * d in _die){...} – Francesco