【问题标题】:null passed to a callee that requires a non-null argument in Xcode 7null 传递给在 Xcode 7 中需要非 null 参数的被调用者
【发布时间】:2015-09-22 08:30:49
【问题描述】:

在 Xcode 7 中,我收到了这个黄色警告: null 传递给需要非 null 参数的被调用者。我的代码如下,第五行突出显示(零部分) (mainVC.currentActiveNVC.viewControllers = nil;) 请帮我。谢谢。

if (!mainVC.isInitialStart)
{
    CGRect openedFrame = mainVC.currentActiveNVC.view.frame;
    [mainVC.currentActiveNVC.view removeFromSuperview];
    mainVC.currentActiveNVC.viewControllers = nil;
    mainVC.currentActiveNVC = nil;

    mainVC.currentActiveNVC = destinationNVC;
    mainVC.currentActiveNVC.view.frame = openedFrame;
    navItem = destinationNVC.navigationBar.topItem;

}

【问题讨论】:

  • 听别人说是因为在iOS9中,需要将其设为空字符串,我尝试将nil替换为“”,但它不起作用,太糟糕了

标签: ios


【解决方案1】:

你可以传递一个空数组。

mainVC.currentActiveNVC.viewControllers = @[];

【讨论】:

    【解决方案2】:

    呜呜呜!!我找到了答案。只需将“nil”更改为“@[]”@[] 表达式用于 iOS9 中的空字符串。

    【讨论】:

    • @[] 是一个空数组,而不是一个空字符串。而且跟iOS9没有关系,是ObjC语言的特性。
    猜你喜欢
    • 2015-09-14
    • 1970-01-01
    • 1970-01-01
    • 2015-12-04
    • 2016-12-16
    • 2022-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多