BOOL变量自动变为“NO”

时间:2015-08-19 13:34:58

标签: ios objective-c boolean reset

我遇到BOOL变量的问题,在函数中间变量的值会自动重置为“NO”: Game.h:

@property BOOL playerTurn;

Players.m:

+(void)playTurnWithBoardPositions:(NSMutableArray*)boardPositions andPlayerTurn:(BOOL)playerTurn//[PlayerTurn(BOOL)'s value is 'YES'
{
//Printing this turn player (X/O)
if (playerTurn) {
    NSLog(@"\nO turn");
}
else
    NSLog(@"\nX turn");
//User input instraction
NSLog(@"\nWhere do you want to insert the %s?",playerTurn?"O":"X");

//Getting user's input (char)
char input[3];
gets(input);
//Converting input to NSString
NSString* inputString=[NSString stringWithUTF8String:input];//PlayerTurn's resets to 'NO'

//Checking user's input and implementing his choice to the board
[Players inputCheckAndImplementWithInputString:inputString andBoardPositions:boardPositions andPlayerTurn:playerTurn];

}

有人知道如何解决这个问题吗? 也许是ARC的东西?

0 个答案:

没有答案