Understanding of 'true' and '@1', is this a same?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Understanding of 'true' and '@1', is this a same?



I try to understand something in Obj-C: I read this Q-A but still I don't understand following use case:



we know that:


#define YES ((BOOL)1)
#define NO ((BOOL)0)



I try to store boolean value into dictionary:



Case 1:


json[@"key"] = @NO;



or


json[@"key"] = @YES;



Case 2:


BOOL isSomeFlag = /* ... */
json[@"key"] = @(!isSomeFlag);



or:


json[@"key"] = @(isSomeFlag);



so I get different results: in 1st case true or false, in 2nd case: @0 or @1


true


false


@0


@1



is this the same? a.e. @0 = false?


@0


false



Do I need to cast to BOOL like: json[@"key"] = @((BOOL)!isSomeFlag);
to get the same results?


BOOL


json[@"key"] = @((BOOL)!isSomeFlag);



Thanks,





Litterals, they are just short code. clang.llvm.org/docs/ObjectiveCLiterals.html
– WrightsCS
2 mins ago











By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived