布尔值'\ x06'而不是默认值'YES'

时间:2012-09-11 11:09:56

标签: objective-c sqlite boolean

执行Sqlite库时,在4或5个步骤之后,将BOOL值捕获为'\ x06'而不是'YES',BOOl值将为'\ 0'..此BOOL值的问题是什么?

BOOL success;//success value is '\x06'
NSLog(@"success:%c",success);

//If the database is present then quit.
if(success)
{
    [self OpenDB:databasePath];
    return;
}

//the database does not exists, so we will copy it to the users document directory]

//Copy the database file to the users document directory.
success = [FileManager copyItemAtPath:dbPath toPath:databasePath error:&error];//  this place success value is '\0'

//If the above operation is not a success then display a message.
//Error message can be seen in the debugger's console window.
if(success)//
    NSAssert1(0, @"Failed to copy the database. Error: %@.", [error localizedDescription]);
[self OpenDB:databasePath];

Am checking success only....

NSLOG输出成功:

1 个答案:

答案 0 :(得分:0)

尝试使用%d代替%c或尝试将默认值设置为成功,
比如BOOL success = NO;

NSLog(@"success: %d", success);