NS_ASSUME_NONNULL_BEGIN Macro

I am following an online tutorial from the command tree tree, and one of the steps is to subclass NSManagedObject for my data model.

When I did this, the code automatically generated a class and a set of macros at the beginning and at the end:

NS_ASSUME_NONNULL_BEGIN

NS_ASSUME_NONNULL_END

I searched on the Internet, but I could not find documentation about what these guys are doing here. By the way, they were defined in the NSObjCRuntime.h header

Any ideas what purpose they serve?

+6
source share
1 answer

This is a handy macro that allows you to print nonnull in headers. The Swift blog post details how new security features were included in Objective-C:

To make it easier to accept new annotations, you can mark certain regions of your Objective-C header files that have been checked for invalidity. In these areas, any simple pointer type will be considered non-zero.

See Nullability and Objective-C - https://developer.apple.com/swift/blog/?id=25

+17
source

All Articles