Hello, I have the following class:
@interface Gamer : CCNode {
NSMutableArray * cards;
}
@property (nonatomic, retain) NSMutableArray * cards;
+(id) CreatePlayer;
-(BOOL)SetCardsArr:(NSMutableArray *) cs;
-(BOOL)GetCardForMove:(Card*) card actionCard:(Card*)selCard;
@end
@implementation Gamer
@synthesize cards;
+(id) CreatePlayer
{
return [[self alloc] init];
}
-(BOOL) SetCardsArr:(NSMutableArray *) cs
{
if (!cs) return NO;
cards = [cs copy];
return YES;
}
-(BOOL)GetCardForMove:(Card*) card actionCard:(Card*)selCard;
{
for (Card * curCard in cards)
{
if ([curCard GetCardSuit] == [selCard GetCardSuit])
{
selCard = curCard;
break;
}
}
return YES;
}
-(id) init
{
if(![super init]) return nil;
return self;
}
- (void)dealloc
{
[cards release];
[super dealloc];
}
@end
On the my main game class I set gamer array with help of the SetCardsArr method. And after some actions I am trying to get Gamer card by GetCardForMove method like this:
Card * moveCard = nil;
Card * selCard = card;
[mGamer GetCardForMove:moveCard actionCard:selCard];
The GetCardForMove function works fine, card found and assigned properly but Card * moveCard is nil :(. I am new to Objective-C and a little confused, please point me on my errors.