【发布时间】:2013-05-31 15:13:21
【问题描述】:
预警:我正在学习适用于 IOS 的 Itunes 斯坦福课程,而且我完全是这种语言的菜鸟。
我的“Deck.m”文件中有这个功能。
- (id)init {
self = [super init];
if (self) {
for (NSString *suit in [Card validSuits]) {
for (NSUInteger rank = 0; rank < [[Card validRanks] count]; rank++) {
Card *card = [[Card alloc] init];
card.contents = [[[Card validRanks] objectAtIndex:rank] stringByAppendingString:suit];
[self.cards addObject:card];
NSLog(@"%@", [self.cards count]);
}
}
}
return self;
}
我的“Card.h”文件中也有这个功能(卡片组由 组成)
@interface Deck : NSObject
@property (nonatomic, strong) NSMutableArray *cards;
- (Card *)drawRandomCard;
@end
我遇到的问题是,当我在运行程序时打印计数时,它始终为 0。当我尝试打印卡片时,它们看起来很好。当我尝试通过索引数组来打印卡片时,它们都是(null)。
怎么了?
【问题讨论】:
标签: objective-c