I know this is a common problem, however I couldn’t find the solution to mine.
I’m following cs193p Standford course, following letter by letter the code at the lecture slides, and Xcode 4.6 still produces an error witch didn’t occur to Xcode 4.4.something…
PlayingCardDeck.h:
#import "Deck.h"
@interface PlayingCardDeck : NSObject
@end
PlayingCardDeck.m:
#import "PlayingCardDeck.h"
#import "PlayingCard.h"
@implementation PlayingCardDeck
...
[self addCard:card atTop:YES]; //problem occurs here
...
@end
deck.h:
#import <Foundation/Foundation.h>
#import "Card.h"
@interface Deck : NSObject
- (void)addCard:(Card *)card atTop:(BOOL)atTop;
...
@end
deck.m:
#import "Deck.h"
@interface Deck()
@property (strong, nonatomic) NSMutableArray *cards;
@end
@implementation Deck
...
- (void)addCard:(Card *)card atTop:(BOOL)atTop
{
if (atTop)
[self.cards insertObject:card atIndex:0];
else
[self.cards addObject:card];
}
...
@end
By logic, addCard:atTop: should be a (+) method? In the lecture it was being a (-) just fine. In addition, after trying to change it to a (+) method, it creates 6 additional problems witch demand using entirely different syntax for each time I’m going for “self”.
In short, I’m really confused by now…
Problem is addCard: atTop is a method of Deck, not a method ofPlayingCardDeck.
Maybe PlayingCardDeck should inherit from Deck? Or there is an iVar of PlayingCardDeck which is a deck?