- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试计算两次之间的持续时间差异。我从 JSONArray 获取持续时间。我使用下面的代码
NSDate *starttime = [[NSDate alloc]init];
NSDate *endtime = [[NSDate alloc]init];
starttime = [currentRecord valueForKey:@"starttime"];
endtime = [currentRecord valueForKey:@"endtime"];
我将上面的值传递给另一个方法
+(NSString*)remaningTime:(NSDate*)startDate endDate:(NSDate*)endDate
{
NSDateComponents *components= [[NSDateComponents alloc]init];
NSString *durationString;
components = [[NSCalendar currentCalendar] components: NSCalendarUnitDay/*|NSCalendarUnitHour|NSCalendarUnitMinute*/ fromDate: endDate toDate: startDate options: 0];
}
但我得到了以下异常
-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x78685f80
2016-12-20 15:21:37.361 nexge[1515:183039] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x78685f80'
*** First throw call stack:
(
0 CoreFoundation 0x03abc212 __exceptionPreprocess + 194
1 libobjc.A.dylib 0x041d3e66 objc_exception_throw + 52
2 CoreFoundation 0x03b353dc -[NSObject(NSObject) doesNotRecognizeSelector:] + 172
3 CoreFoundation 0x03a3b34c ___forwarding___ + 1052
4 CoreFoundation 0x03a3af0e _CF_forwarding_prep_0 + 14
5 CoreFoundation 0x03a9b419 -[__NSCFCalendar components:fromDate:toDate:options:] + 393
6 CoreFoundation 0x03a9b217 -[_NSCopyOnWriteCalendarWrapper components:fromDate:toDate:options:] + 103
7 nexge 0x0003c2c8 +[callRecords remaningTime:endDate:] + 248
8 nexge 0x0003c0f9 -[callRecords initWithCallAmount:duration:start:end:destination:] + 393
9 nexge 0x00036321 -[callRecordsDataController addRecordWithCallAmount:duration:start:end:destination:] + 257
10 nexge 0x00036d0d -[callRecordsDataController connectionDidFinishLoading:] + 1165
11 CFNetwork 0x00464850 ___ZL32_NSURLConnectionDidFinishLoadingP16_CFURLConnectionPKv_block_invoke + 55
12 CFNetwork 0x004603b8 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 71
13 CFNetwork 0x00460369 -[NSURLConnectionInternalConnection invokeForDelegate:] + 142
14 CFNetwork 0x004602c7 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 188
15 CFNetwork 0x004601f7 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 42
16 CFNetwork 0x00464814 _ZL32_NSURLConnectionDidFinishLoadingP16_CFURLConnectionPKv + 36
17 CFNetwork 0x00464769 ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 96
18 CFNetwork 0x00685f81 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 107
19 libdispatch.dylib 0x04cb0cc3 _dispatch_client_callout + 14
20 libdispatch.dylib 0x04c895f2 _dispatch_block_invoke_direct + 380
21 libdispatch.dylib 0x04c9497f ___dispatch_block_create_block_invoke + 20
22 CFNetwork 0x004600ce _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 24
23 CoreFoundation 0x03a06ef9 CFArrayApplyFunction + 57
24 CFNetwork 0x0045ffc9 _ZN19RunloopBlockContext7performEv + 139
25 CFNetwork 0x005664a8 _ZThn16_N19RunloopBlockContext24multiplexerClientPerformEv + 20
26 CFNetwork 0x0045fe65 _ZN17MultiplexerSource7performEv + 319
27 CFNetwork 0x0045fc84 _ZN17MultiplexerSource8_performEPv + 62
28 CoreFoundation 0x03a5bcbf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
29 CoreFoundation 0x03a3fdf7 __CFRunLoopDoSources0 + 519
30 CoreFoundation 0x03a3f284 __CFRunLoopRun + 1124
31 CoreFoundation 0x03a3ebab CFRunLoopRunSpecific + 395
32 CoreFoundation 0x03a3ea0b CFRunLoopRunInMode + 123
33 GraphicsServices 0x0575eb4c GSEventRunModal + 177
34 GraphicsServices 0x0575e9c7 GSEventRun + 80
35 UIKit 0x0225c32b UIApplicationMain + 148
36 nexge 0x0003702c main + 140
37 libdyld.dylib 0x04ceb799 start + 1
38 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
最佳答案
您正在向需要 NSDate 的地方发送字符串数据。类型不匹配导致您的应用程序崩溃。在使用函数之前,您必须将字符串转换为日期,以下是您可以如何转换。
NSString *dateStr = @"2016/12/20 12:53:58 +0000";
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy/MM/dd HH:mm:ss Z"];
NSDate *date = [dateFormat dateFromString:dateStr];
注意:yyyy/MM/dd HH:mm:ss Z 是我用来显示示例的日期格式,您已根据字符串更改此格式。
//date是你需要传递的,
你必须为你的约会对象做这件事,
关于ios - __NSCFString timeIntervalSinceReferenceDate] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41239768/
我知道我的问题有点含糊,但我不知道如何描述它。我问过很多地方,但似乎没有人理解我为什么要这样做。但请耐心等待,我会解释为什么我想要这样的东西。 我使用 Liquid Templates 允许用户在我的
这个问题在这里已经有了答案: what is the difference between null != object and object!=null [duplicate] (2 个回答) 7年
当我在我的本地主机 Google App Engine 应用程序中将日志记录级别更改为 FINE 时,我开始在我的跟踪堆栈中看到这些: Apr 17, 2013 4:54:20 PM com.goog
Python 有内置函数 type : class type(object) With one argument, return the type of an object. The return v
我正在使用深度学习进行语义分割,我遇到了以下术语:语义分割、实例检测、对象检测 和对象分割. 它们有什么区别? 最佳答案 这些术语的某些用法对用户而言是主观的或依赖于上下文,但据我所知对这些术语的合理
我面临 -[NSConcreteMutableData release] 的问题:消息发送到已释放的实例,我也附上了我的示例代码。 - (IBAction)uploadImage { NSString
我试图显示模型中的单个实例(数据库行),其中多个实例共享多行的相同字段(列)值。为了澄清这一说法,我有以下情况: ID/Title/Slug/Modified 1 Car A 1s ag
我正在尝试使用mockito来模拟服务。然而,我没有找到一种方法来告诉mockito,给定一个类的实例返回给我相同的实例: 类似于: given(service.add(any(Individua
我知道如何从父类(super class)原型(prototype)创建子类原型(prototype)。但是,如果我已经有了父类(super class)对象的实例来创建子类对象怎么办? 在 JS 中
鉴于 Kotlin 1.1。对于某个类的 instance,instance::class.java 和 instance.javaClass 似乎几乎是等价的: val i = 0 println(
这个问题在这里已经有了答案: 8年前关闭。 Possible Duplicate: Find out the instance id from within an ec2 machine 我正在寻找从
为什么我的 Instantiate 函数没有创建 That 的“空白”实例? 我有以下最小类: classdef That < handle properties This = '' end
Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTra
考虑以下几点: public class A { public String name = "i am a A instance"; } public class B extends A {
我正在使用 Scalr 来扩展网站服务器。 在 Apache 服务器上,我安装了 Sakai,并为 Linux 机器创建了一个启动脚本。 问题是,如何确保MySQL实例在Apache服务器启动之前启动
Android Realm DB 允许使用 Realm.getInstance() 获取多个实例。这些中的最佳实践是什么? :1.创建单个实例(应用程序范围)并在任何地方使用它2. 在需要时获取一个新
我很难理解为什么修改实例 a 中的属性会修改实例 b 中的相同属性。 var A = function (){ }; A.prototype.data = { value : 0 }; var
我将 Weka 用作更长管道的一部分,因此,我无法承受将所有数据写入文件或数据库只是为了创建一个 Instances。目的。我可以即时做的是创建 Instance 的列表对象。 来自 this pag
class C: def func(self, a): print(a) c = C() print(c.__dict__) # {} c.func = c.func # c.func i
Angular Routing 文档提到了组件实例创建、组件实例激活和路由激活。 文档没有解释这些概念的区别,以及每次创建/激活发生的时间。 问题 实例创建和实例激活有什么区别? 实例激活和路由激活有
我是一名优秀的程序员,十分优秀!