Not knowing how your accessors will be configured, it will be difficult to troubleshoot the code as is. In this case, you need to configure your accessors and code:
Manager.h
@interface Manager
{
Player *p1, *p2, *mCurrentPlayer, *mCurrentOpponent;
}
@property (nonatomic, retain) Player *p1;
@property (nonatomic, retain) Player *p2;
@property (nonatomic, assign) Player *mCurrentPlayer;
@property (nonatomic, assign) Player *mCurrentOpponent;
@end
Manager.m
-(void) initPlayers {
self.p1 = [[[Player alloc] init] autorelease];
self.p2 = [[[Player alloc] init] autorelease];
self.mCurrentPlayer = self.p1;
self.mCurrentOpponent = self.p2;
}
-(void) swapPlayers {
Player * temp = self.mCurrentPlayer;
self.mCurrentPlayer = self.mCurrentOpponent;
self.mCurrentOpponent = temp;
}
source
share