Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicklockwood/NullSafe
NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception
https://github.com/nicklockwood/NullSafe
Last synced: 3 months ago
JSON representation
NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception
- Host: GitHub
- URL: https://github.com/nicklockwood/NullSafe
- Owner: nicklockwood
- License: other
- Created: 2012-12-19T10:08:40.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-08-14T15:29:54.000Z (about 1 year ago)
- Last Synced: 2024-08-01T08:04:28.962Z (3 months ago)
- Language: Objective-C
- Homepage:
- Size: 31.3 KB
- Stars: 1,941
- Watchers: 59
- Forks: 361
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- Awesome-iOS - NullSafe - NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception (Foundation)
README
[![Build Status](https://travis-ci.org/nicklockwood/NullSafe.svg)](https://travis-ci.org/nicklockwood/NullSafe)
Purpose
--------------NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception. This eliminates a common cause of crashes, where (for example) JSON data contains a null value instead of an array or string, and the network code in the app isn't expecting it.
Supported iOS & SDK Versions
-----------------------------* Supported build target - iOS 12.0 / Mac OS 10.14 (Xcode 10.1)
* Earliest supported deployment target - iOS 9.0 / Mac OS 10.10
* Earliest compatible deployment target - iOS 4.3 / Mac OS 10.6NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this iOS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.
ARC Compatibility
------------------NullSafe works in both ARC and non ARC targets without modification.
Installation & Usage
--------------------To use NullSafe, just drag the NullSafe.m file into your project. NullSafe will be automatically loaded at runtime, you don't need to include any header files in your code.
Selectively Disabling NullSafe
------------------------------NullSafe is enabled automatically as soon as the class files are added to a project target, however if you wish to disable NullSafe for a particular scheme (e.g. when running in debug mode) then you can disable it by adding the following pre-compiler macro to your build settings:
NULLSAFE_ENABLED=0
Or if you prefer, you could add something like this to your prefix.pch file:
#ifdef DEBUG
#define NULLSAFE_ENABLED 0
#endifRelease Notes
--------------Version 2.0
- Radically simplified NullSafe to only handle JSON and Plist values
Version 1.2.3
- Updated for Xcode 9
- Fixed thread safety issue
- Added tvOS support to podspecVersion 1.2.2
- Fixed nullability warningVersion 1.2.1
- Fixed crash in iOS 8
- Removed NullSafe.h file (redundant)
- Now complies with -Weverything warning levelVersion 1.2
- Will now handle any known method, not just a subset
- Added NULLSAFE_ENABLED macro to easily enable/disable per scheme
- Added implementation cache for better performanceVersion 1.1
- Made it work by design rather than coincidence ;-)
Version 1.0
- Initial release