他們不是。
其中宣佈方法用括號的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,整個方法塊已經被標記爲返回非空值。)看起來像這些方法上的文檔應該列出它們爲非空。 –