gpt4 book ai didi

ios - [NSCFString timeIntervalSinceReferenceDate] : unrecognized selector sent to instance

转载 作者:可可西里 更新时间:2023-11-01 05:04:13 28 4
gpt4 key购买 nike

我想比较两个日期之间的差异,但是使用下面的代码我得到了错误“[NSCFString timeIntervalSinceReferenceDate]:无法识别的选择器发送到实例。”代码有什么问题?

NSDate *dateAdded=[eventDictionary objectForKey:@"dateAdded"];
NSDate *validUntilDate=[eventDictionary objectForKey:@"validUntilDate"];
NSDateComponents *sometimeAgo = [[NSCalendar currentCalendar] components:(NSSecondCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:dateAdded toDate:validUntilDate options:0];

最佳答案

看起来 dateAdded 和/或 validUntilDate 实际上是字符串而不是日期。也许它们是表示日期的字符串,但毕竟是字符串。

关于ios - [NSCFString timeIntervalSinceReferenceDate] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6479421/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com