[[NSDate alloc] init]

时间:2017-01-20 09:43:12

标签: ios objective-c nsdate

我的代码非常简单:

NSDate * curDate = [[NSDate alloc] init];
return (int64_t)([curDate timeIntervalSince1970] * 1000);

但是我遇到了以下堆栈跟踪的市场崩溃问题:

  

线程227崩溃:0 libsystem_c.dylib
    0x000000018d2af4bc __abort + 176(abort.c:140)1 libsystem_c.dylib     0x000000018d2af4bc __abort + 176(abort.c:140)2 libsystem_c.dylib     0x000000018d2af40c abort + 152(abort.c:99)3
  libsystem_malloc.dylib 0x000000018d37fa5c nanozone_error + 332   (nano_malloc.c:82)4 libsystem_malloc.dylib
    0x000000018d381be0 _nano_malloc_check_clear + 412(nano_malloc.c:660)   5 libsystem_malloc.dylib 0x000000018d380be8 nano_calloc + 80   (nano_malloc.c:892)6 libsystem_malloc.dylib
    0x000000018d372168 malloc_zone_calloc + 152(malloc.c:1367)7
  libsystem_malloc.dylib 0x000000018d3720ac calloc + 40   (malloc.c:1643)8 libobjc.A.dylib 0x000000018cdaf624   class_createInstance + 76(objc-runtime-new.mm:6376)9
  CoreFoundation 0x000000018e374c9c __CFAllocateObject +   28(NSObject.m:1005)10 CoreFoundation
    0x000000018e2472d4 + [__ NSDate __new:] + 20(NSDate.m:67)11   CoreFoundation 0x000000018e2472b0    - [__ NSPlaceholderDate initWithTimeIntervalSinceReferenceDate:] + 112(NSDate.m:199)

对于在alloc中可能出现什么问题以及修复它的可能方法有任何想法吗?

1 个答案:

答案 0 :(得分:0)

应该是:

if ((this != null)