I’ve got a managed object with an NSNumber that’s just a Boolean value. When the user clicks a button I want to toggle that.
self.item.completed = [NSNumber numberWithBool:![self.item.completed boolValue]];
Is there a cleaner (or perhaps just more compact) way that I’m missing?
There is little you can do to the process of producing the negated value, but you can make the syntax of invoking it look less bulky by hiding your code in a category:
Now you can use the new method like this:
You could also set up an
NSArraywith inversions, and use it as follows: