
I am completing a Matchismo assignment from the Stanford website.
So far I have been following the slides exactly as they are.
In addition, this error appears only when I implement the last method, that is, the recipient. If I remove the getter, no problem.
Notes can be downloaded here: Stanford Course Website
thank
the code:
.m file:
#import "playingCard.h"
@implementation playingCard
-(NSString *) contents
{
NSArray *rankStrings = @[@"?",@"A",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"J",@"Q",@"K"];
return [rankStrings[self.rank] stringByAppendingString:self.suit];
}
-(void) setSuit:(NSString *) suit
{
if([@[@"♣︎",@"♥︎",@"♦︎",@"♠︎"] containsObject:suit])
{
_suit = suit;
}
}
- (NSString *)isSuit
{
return _suit ? _suit : @"?";
}
@end
.h file:
#import "card.h"
@interface playingCard : card
@property(strong, nonatomic, getter=isSuit) NSString *suit;
@property(nonatomic) NSUInteger rank;
@end
source
share