iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – Xcode 7,Obj-C,“Null传递给需要非空参数的被调用者”大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

在Xcode 7中,我收到这个警告: Null passed to a callee that requires a non-null argument ..从这个nil初始化一个NSMutableArray … sectiontitles = [[NSMutableArray alloc] initWithObjects:nil]; 我发现@R_14_10675@用removeAllObjects。 [sect
在Xcode 7中,我收到这个警告:

Null passed to a callee that requires a non-null argument

..从这个nil初始化一个NSMutableArray …

sectiontitles = [[NSMutableArray alloc] initWithObjects:nil];

我发现@R_14_10675@用removeAllObjects。

[sectiontitles removeAllObjects];

但是,这不允许我评估一个sectiontitles.count == 0.我没有尝试sectiontitles == nil,但是除非我使用iniWithObjects我以后不能添加对象。

当我刷新数据源时,当没有记录时,我需要将数组设置为零或零。我似乎无法使用addObject来添加项目,除非我已经使用了initWithObjects。

解决方法

你为什么不试试:

sectiontitles = [[NSMutableArray alloc] init];

或以下任何一种:

sectiontitles = [[NSMutableArray alloc] initWithCapacity:sectiontitles.count];
sectiontitles = [NSMutableArray new];
sectiontitles = [NSMutableArray array];
sectiontitles = [NSMutableArray arrayWithCapacity:sectiontitles.count];

也许有些愚蠢的:

sectiontitles = [NSMutableArray arrayWithArray:@[]];
sectiontitles = [@[] mutableCopy];

有很多方法来创建空的可变数组。只要看了doc

大佬总结

以上是大佬教程为你收集整理的ios – Xcode 7,Obj-C,“Null传递给需要非空参数的被调用者”全部内容,希望文章能够帮你解决ios – Xcode 7,Obj-C,“Null传递给需要非空参数的被调用者”所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。