I am doing the Matchismo assignment from the Stanford website.
So far I have followed the slides exactly the way they are.
Also, this error only shows up when I implement the last method i.e. the getter. If I remove the getter, there's no issue.
The notes can be downloaded from here: Stanford Course Website
Thanks
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
Adding one line does the trick!
@synthesize suit = _suit;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With