【发布时间】:2014-07-13 12:47:50
【问题描述】:
我想用
for (TBL_CardView *cardView in cardsInHand)
{
// <#statements#>
}
TBL_CardView 是我的自定义类,cardsInHand 只是 (TBL_CardViewArray*)
所以我需要为我的TBL_CardViewArray 类实现countByEnumeratingWithState:objects:count:。
这是正确的吗?
这是我的 TBL_CardViewArray.h
/**
* Keep TBL_CardView in array
*/
@interface TBL_CardViewArray : NSObject
- (TBL_CardView *)drawCard;
- (void)addCard:(TBL_CardView *)card;
- (NSUInteger)cardsRemaining;
- (NSArray*) cardViewArray;
- (TBL_CardView *)drawRandomCard;
@end
TBL_CardViewArray.m 中的一些重要部分
@implementation TBL_CardViewArray
{
NSMutableArray *_cards;
}
所以我只是在 NSMutableArray 周围使用 TBL_CardViewArrayas 包装器来存储我的 TBL_CardViewclass。
问题
如何为我的TBL_CardViewArray 类实现 countByEnumeratingWithState:objects:count:。
我用谷歌搜索过,但没有找到可以轻松重复使用的示例。
我的假设是,因为我已经在使用 NSMutableArray 进行存储,所以它并不复杂,但我不知道怎么做?
【问题讨论】:
标签: ios objective-c nsmutablearray nsfastenumeration