Everytime when I tried to convert BOOL value into int. INT value is showing -8 for True and 0 for False. Ideally it should return 1 for true.
I have tried all possible ways of conversion like
int val=Info.isattachementDownloadable;
int val=[[NSString stringWithFormat:@"%d", Info.isattachementDownloadable] intValue];
int val=(int)Info.isattachementDownloadable;
where Info.isattachementDownloadable
return BOOL
In all ways its showing -8 for TRUE.
Any suggestion ?
Master C and Embedded C Programming- Learn as you go Bool is a datatype in C++, and we can use true or false keyword for it. If we want to convert bool to int, we can use typecasting. Always true value will be 1, and false value will be 0.
Use int for casting a Boolean value in Python. Using int() method will convert Boolean to Int, 1 for True and 0 for False.
First, you cannot implicitly convert from bool to int. The C# compiler uses this rule to enforce program correctness. It is the same rule that mandates you cannot test an integer in an if statement.
Maybe that will help(thought i don't know why it may be needed in the first place)
NSInteger i = @(YES).integerValue;
Hope that it helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With