检查数组是否包含对象问题

时间:2014-02-07 15:16:20

标签: ios objective-c arrays nsarray

为什么这段代码不会触发?数组包含0个对象,所以我认为array.count == 0应该在这种情况下起作用。

enter image description here

相反,代码转到else语句。我究竟做错了什么?或者可能导致这种情况的原因是什么?

代码:

if (indexPath.section == 0) {
    if (!newEvents || newEvents.count == 0)
    {
        // Do stuff
    }
    else
    {
        // do stuff
    }
}
else
{
    if (!oldEvents || oldEvents.count == 0)
    {
        // Do stuff
    }
    else
    {
        // Do stuff
    }
}

修改

在进一步研究之后,我发现这不是射击,看起来另一个不是: enter image description here

以下是一些可能对您很重要的代码。

enter image description here

0 个答案:

没有答案
相关问题