比较两个 NSDate 失败 [英] compare two NSDate fails

查看:31
本文介绍了比较两个 NSDate 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试比较两个 NSDate 对象.但它总是失败,我看不出哪里出了问题.

I try to compare two NSDate objects. But it fails all the time and I can not see what is wrong.

  -(IBAction)nextAction
{
    NSDate *today = [NSDate date];
    if([appStateDate compare:today] == NSOrderedAscending) {
        dispatch_async(calcQueue, ^{ [self plusOneDate]; });
    }
}

没有代码就可以正常工作.

Without the code it works fine.

它只是崩溃了,并且在主方法的这一行上有 EXE_BAD_ACCESS.

it just crashes, and EXE_BAD_ACCESS on this line in the main method.

 int retVal = UIApplicationMain(argc, argv, nil, nil);

和打印

'+[ compare:]: unrecognized selector sent to class 0x634d7e0`'

我不擅长使用调试器,所以如果你知道任何好的教程或指南,我想知道它们;) 对不起我的英语

Im not good at using the debugger, so if you know any good tutorials or guides i like to know them to ;) sorry for my english

推荐答案

看起来 appStateDate 未初始化,或者包含 NSDate 以外的内容.你在哪里初始化它?

Looks like appStateDate is not initialized, or contains something other than a NSDate. Where do you intitialize it?

这篇关于比较两个 NSDate 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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