finds.dev

nicklockwood/NullSafe

NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception

View on GitHub

★ 1,939Objective-CNOASSERTIONupdated Aug 2023

// the take

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.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
1,939
Forks
356
Language
Objective-C
License
NOASSERTION
Last commit
14 Aug 2023

// nearby

If NullSafe isn't quite it.

All repos →