1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::objc::NSObject;

objc_subclass! {
    /// A singleton object used to represent null values in collection objects that
    /// don’t allow `nil` values.
    ///
    /// See [documentation](https://developer.apple.com/documentation/foundation/nsnull).
    pub class NSNull: NSObject<'static>;
}

impl Default for &NSNull {
    #[inline]
    fn default() -> Self {
        NSNull::null()
    }
}

impl NSNull {
    /// Returns the singleton instance.
    ///
    /// See [documentation](https://developer.apple.com/documentation/foundation/nsnull).
    #[inline]
    #[doc(alias = "kCFNull")]
    pub fn null() -> &'static Self {
        extern "C" {
            // `NSNull` is toll-free bridged with `CFNullRef` whose only
            // instance is this.
            static kCFNull: &'static NSNull;
        }
        unsafe { kCFNull }
    }
}