I'm writing a set of tools in Objective-C that will be used by Swift at some point so I'm using generics and nullability. What am I supposed to do in this situation?
- (NSArray<MyObj *> * __nullable)foo:(NSError **)error;
Currently I'm getting a warning: Pointer is missing a nullability type specifier...
for both pointers! I'm almost certain that I'm NOT to supposed to do:
- (NSArray<MyObj *> * __nullable)foo:(NSError * __autoreleasing __nullable * __nullable)error;
Am I?
The Swift blog entry Nullability and Objective-C states:
However, this remark is listed as an exception to the rules of "Audited Regions", and it seems that it applies only within an audited region:
Within an audited region, any simple pointer type will be assumed to be
nonnull
(with some exceptions as the above-mentioned forNSError
).Outside of an audited region, you actually have to write explicitly
to avoid warnings about missing nullability type specifiers.
(
_Nullable
is the newer syntax used in Xcode 7 and replaces__nullable
.)