从预期返回非空值的方法返回的Nil [英] Nil returned from a method that is expected to return a non-null value

查看:52
本文介绍了从预期返回非空值的方法返回的Nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现 UIKeyInput UITextInputTraits UITextInput 并且需要执行以下操作:

I'm implementing UIKeyInput, UITextInputTraits, and UITextInput and with that I'm required to implement:

- (NSArray *)selectionRectsForRange:(UITextRange *)range
{
    return nil;
}

但是,在分析我的项目时,我得到:没有方法返回预计将返回非空值。

However, in analyzing my project I get: "nil returned from a method that is expected to return a non-null value".

摆脱这种情况的正确方法是什么?我应该中止吗?

What would be the correct way to get rid of this? Should I do an abort?

推荐答案

不返回 nil 。如果没有要返回的
UITextSelectionRects,则返回一个空数组。

Don't return nil. If you have no UITextSelectionRects to return, return an empty array.

这篇关于从预期返回非空值的方法返回的Nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆