Forewarning: I'm going through the Itunes Stanford course for IOS, and I'm a complete noob with this language.
I have this function in my "Deck.m" file.
- (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;
}
I also have this function in my "Card.h" file (which deck is composed of )
@interface Deck : NSObject
@property (nonatomic, strong) NSMutableArray *cards;
- (Card *)drawRandomCard;
@end
The problem I'm having is that when I print the count when running the program, it's always 0. When i try to print the card, they look fine. When I try to print the card by indexing the array, they're all (null).
What's wrong?