News for hackers. Stuff that matters.
Re:Is Objective-C BOOL a boolean type? It depends by dottrap on Wednesday January 10, 2024 @05:13PM (#38944113)
> IMHO there wasn’t any reason to bother fiddling with the definition of BOOL.

There were good reasons to change this to a real boolean. I think it was a WWDC, where kind of discussing this topic, one Apple engineer said they did an audit of production Obj-C code and found multiple instances where their BOOL values were values other than 0 or 1 (which was considered surprising and ultimately bugs).

This can lead to all sorts of subtle problems. One common one encountered by framework users is where something returns a BOOL and the user explicitly compared against == YES or == NO. If the value is say 2, then this code usually results in wrong decision.

There are no comments on this comment yet.