NS_ASSUME_NONNULL_BEGIN Macro

IosObjective CXcode

Ios Problem Overview


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

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

NS_ASSUME_NONNULL_BEGIN

NS_ASSUME_NONNULL_END

I was searching online but I could not find any documentation about what these guys are doing here. By the way they were defined in the header NSObjCRuntime.h

Any ideas what purpose they serve?

Ios Solutions


Solution 1 - Ios

It's a convenience macro to save you typing nonnull in your headers. From the Swift blog detailing how new safety features have been incorporated back in Objective-C:

> To ease adoption of the new annotations, you can mark certain regions > of your Objective-C header files as audited for nullability. Within > these regions, any simple pointer type will be assumed to be nonnull.

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser5412293View Question on Stackoverflow
Solution 1 - IosDDPView Answer on Stackoverflow