// the find
nicklockwood/NullSafe
NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception
NullSafe swallows unrecognized messages sent to NSNull, returning nil instead of crashing. It exists to paper over the common iOS bug where JSON null values end up in places that expect strings or arrays and then receive a method call. One .m file, drops into any Objective-C project.
The v2 simplification was the right call — earlier versions tried to handle arbitrary selectors which was a much scarier surface area. The NULLSAFE_ENABLED macro lets you turn it off in debug builds so crashes stay visible during development, which is the correct tradeoff. Zero integration friction: no headers, no configuration, just drag in the file.
This is Objective-C only and last touched in 2023 — Swift codebases have had proper Optional handling since 2014, so this entire problem class is irrelevant there. The real fix is defensive JSON parsing at the network boundary, not runtime message swallowing; using this in production means crashes become silent bad state, which can be harder to debug than the original crash. Travis CI badge links to a service that's effectively dead for open source. Minimum deployment target of iOS 9 in the docs, but realistically any new Objective-C project targeting iOS 9 in 2024 is a legacy maintenance situation.