Comment

Comment by anon1385

>Use the bitwise AND operator & to check for a selected bitmask enumeration value.

You should take care if you store result of this in a BOOL (or pass it to a method or function that takes a BOOL). BOOL is only char big and plenty of common Cocoa bitmasks don't have any bits set in that range. For example NSEventMaskEndGesture is (1<<20).

  NSEventMask mask = NSEventMaskEndGesture;
  BOOL end = mask & NSEventMaskEndGesture;
  if (!end) NSLog(@"Oops");
parent anon1385 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton