他们不是。
其中宣布方法用括号的the "assume nonnull" macros头:
//
// UITextInput.h
// UIKit
//
// Copyright (c) 2009-2017 Apple Inc. All rights reserved.
//
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UITextInputTraits.h>
#import <UIKit/UIResponder.h>
//===================================================================================================
// Responders that implement the UIKeyInput protocol will be driven by the system-provided keyboard,
// which will be made available whenever a conforming responder becomes first responder.
NS_ASSUME_NONNULL_BEGIN
// snip
// ...
// L150
/* Geometry used to provide, for example, a correction rect. */
- (CGRect)firstRectForRange:(UITextRange *)range;
- (CGRect)caretRectForPosition:(UITextPosition *)position;
- (NSArray *)selectionRectsForRange:(UITextRange *)range NS_AVAILABLE_IOS(6_0); // Returns an array of UITextSelectionRects
所以这种方法实际上已经被标记为具有非空返回值。
迂腐,但该方法没有明确标记为具有非空返回值。这将需要使用' - (NSArray * _Nonnull)选择...'。使用'NS_ASSUME_NONNULL_BEGIN' *隐式地标记所有方法直到'NS_ASSUME_NONNULL_END'。 – rmaddy
很酷。谢谢。 (而且rmaddy,整个方法块已经被标记为返回非空值。)看起来像这些方法上的文档应该列出它们为非空。 –