久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

一直可靠工作的時間戳功能只是導致 EXC_BAD_INST

Timestamp function that has been working reliably just caused EXC_BAD_INSTRUCTION(一直可靠工作的時間戳功能只是導致 EXC_BAD_INSTRUCTION)
本文介紹了一直可靠工作的時間戳功能只是導致 EXC_BAD_INSTRUCTION的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我一直在使用這個函數來生成時間戳.我在 Stack Overflow 上的某個地方找到了它.

I have been using this function to generate a time stamp. I found it somewhere here on Stack Overflow.

@objc public class var timestamp: String {
    return "(Int(NSDate().timeIntervalSince1970 * 1000))"
}

它一直在正常工作,但我剛剛收到一個 EXC_BAD_INSTRUCTION:

It has been working without issue, but I just got a EXC_BAD_INSTRUCTION:

fatal error: floating point value cannot be converted to Int because it is greater than Int.max

隨著這個應用程序的開發接近完成,突然間看到它導致 EXC_BAD_INSTRUCTION 讓我感到緊張.這是在模擬器中運行的,但我設置了有效的日期和時間.

As the development of this app is nearing completion it makes me nervous to all of the sudden see it cause a EXC_BAD_INSTRUCTION. This is running in the Simulator, but I have a valid date and time set.

任何想法或建議或非常感謝.下面是回溯.

Any ideas or suggestions or are greatly appreciated. Below is the backtrace.

(lldb) bt
* thread #1: tid = 0x15c4d, 0x04a30393 libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> () + 67, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
frame #0: 0x04a30393 libswiftCore.dylib function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt) -> () + 67
* frame #1: 0x00afe0c9 TDTPhotoLib static     
TDTDeviceUtilites.timestamp.getter(self=TDTPhotoLib.TDTDeviceUtilites) + 409 at TDTDeviceUtilites.swift:127
frame #2: 0x00166979 Oilist TDTPaintingViewController.finshedSession(sender=0x7aee0fb0, self=0x7e9d3800) -> () + 169 at TDTPaintingViewController.swift:1370
frame #3: 0x00102896 Oilist TDTOilistMenuPainting.goForward(sender=0x7aee0fb0, self=0x7c218770) -> () + 374 at TDTOilistMenuPainting.swift:149
frame #4: 0x0010290d Oilist @objc TDTOilistMenuPainting.goForward(UIButton!) -> () + 61 at TDTOilistMenuPainting.swift:0
frame #5: 0x018a80b5 libobjc.A.dylib -[NSObject performSelector:withObject:withObject:] + 84
frame #6: 0x0336ee38 UIKit -[UIApplication sendAction:to:from:forEvent:] + 118
frame #7: 0x0336edb7 UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #8: 0x03512f3b UIKit -[UIControl sendAction:to:forEvent:] + 79
frame #9: 0x035132d4 UIKit -[UIControl _sendActionsForEvents:withEvent:] + 433
frame #10: 0x035122c1 UIKit -[UIControl touchesEnded:withEvent:] + 714
frame #11: 0x033ef52e UIKit -[UIWindow _sendTouchesForEvent:] + 1095
frame #12: 0x033f05cc UIKit -[UIWindow sendEvent:] + 1159
frame #13: 0x03391be8 UIKit -[UIApplication sendEvent:] + 266
frame #14: 0x03366769 UIKit _UIApplicationHandleEventQueue + 7795
frame #15: 0x02423e5f CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #16: 0x02419aeb CoreFoundation __CFRunLoopDoSources0 + 523
frame #17: 0x02418f08 CoreFoundation __CFRunLoopRun + 1032
frame #18: 0x02418846 CoreFoundation CFRunLoopRunSpecific + 470
frame #19: 0x0241865b CoreFoundation CFRunLoopRunInMode + 123
frame #20: 0x07031664 GraphicsServices GSEventRunModal + 192
frame #21: 0x070314a1 GraphicsServices GSEventRun + 104
frame #22: 0x0336ceb9 UIKit UIApplicationMain + 160
frame #23: 0x00131ed1 Oilist main + 145 at AppDelegate.swift:14
frame #24: 0x05631a25 libdyld.dylib start + 1

推薦答案

你的代碼會在所有 32 位平臺(如 iPhone 4、5)上崩潰因為

Your code will crash on all 32-bit platforms (such as iPhone 4, 5) because the result of

NSDate().timeIntervalSince1970 * 1000
// E.g.: 1464850525047.38

不適合 32 位整數.作為解決方案,使用 64 位整數:

does not fit into a 32-bit integer. As a solution, use 64-bit integers:

Int64(NSDate().timeIntervalSince1970 * 1000)

或者,如果打算創建一個 string 表示毫秒,使用字符串格式而不是整數轉換:

Alternatively, if the intention is to create a string representing the milliseconds, use string formatting instead of an integer conversion:

String(format:"%.0f", NSDate().timeIntervalSince1970 * 1000)

這篇關于一直可靠工作的時間戳功能只是導致 EXC_BAD_INSTRUCTION的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 日韩欧美在线观看一区 | 国产情侣啪啪 | 精品久久久久久一区二区 | 综合久久99 | 日韩区| 欧美专区在线 | 日韩一级欧美一级 | 久久这里只有精品首页 | 欧美视频免费在线 | 欧美精品国产一区二区 | 国产精品视频免费观看 | 国产精品久久久久久久久久软件 | 97国产精品视频人人做人人爱 | 亚洲毛片在线观看 | 中文字幕综合在线 | 亚洲视频免费在线观看 | 91成人精品视频 | 久久久久久久久久久一区二区 | 欧美日韩久| 欧美激情精品久久久久久 | 久久国产日韩 | 国产成人免费网站 | 成人免费视频网站在线观看 | 国产欧美精品一区二区三区 | 人人人干| 国产成人精品一区二三区在线观看 | 激情综合五月 | 成人激情视频在线 | 日本三级全黄三级三级三级口周 | 一区二区三区四区免费视频 | 一区二区三区四区不卡 | 龙珠z在线观看 | 免费激情| 激情欧美日韩一区二区 | 天天人人精品 | 久久综合九九 | 日韩一区二区免费视频 | 日本一区二区三区精品视频 | jlzzjlzz国产精品久久 | 日韩欧美三级在线 | 颜色网站在线观看 |