Ios 显示第0行发生故障的故障报告?
谁能帮我解开这起车祸报告的神秘面纱 没有异常名称或原因,回溯显示崩溃发生在包含崩溃的Ios 显示第0行发生故障的故障报告?,ios,swift,crash-reports,Ios,Swift,Crash Reports,谁能帮我解开这起车祸报告的神秘面纱 没有异常名称或原因,回溯显示崩溃发生在包含崩溃的init方法的文件的第0行。什么 崩溃线程的第一对符号行: 0 AppName 0x000000010008c370 init (article, $metatype) (ArticleImageProvider.swift:0) 1 AppName 0x000000010006b0c4 shareArticleActivityViewController (article, track) (Basi
init
方法的文件的第0行。什么
崩溃线程的第一对符号行:
0 AppName 0x000000010008c370 init (article, $metatype) (ArticleImageProvider.swift:0)
1 AppName 0x000000010006b0c4 shareArticleActivityViewController (article, track) (BasicArticleSharingController.swift:28)
2 AppName 0x0000000100063198 sharePressed () (DetailsViewController.swift:202)
3 AppName 0x00000001000600c8 sharePressed () (DetailsViewController.swift:200)
4 AppName 0x00000001000bfa8c sharePressed () (ContentNavView.swift:108)
5 AppName 0x000000010022f4b4 __55-[ASControlNode sendActionsForControlEvents:withEvent:]_block_invoke (ASControlNode.m:360)
6 AppName 0x000000010022f21c -[ASControlNode sendActionsForControlEvents:withEvent:] (ASControlNode.m:381)
7 AppName 0x000000010022e5b8 -[ASControlNode touchesEnded:withEvent:] (ASControlNode.m:191)
8 AppName 0x000000010026185c -[_ASDisplayView touchesEnded:withEvent:] (_ASDisplayView.mm:173)
9 UIKit 0x0000000187613d8c forwardTouchMethod + 260
10 UIKit 0x00000001874b0a2c -[UIWindow _sendTouchesForEvent:] + 696
11 UIKit 0x00000001874a9f68 -[UIWindow sendEvent:] + 680
12 UIKit 0x000000018747d18c -[UIApplication sendEvent:] + 260
13 UIKit 0x000000018771e324 _UIApplicationHandleEventFromQueueEvent + 15420
14 UIKit 0x000000018747b6a0 _UIApplicationHandleEventQueue + 1712
下面是一些代码:
// Where I attach the action to my button in ContentNavView
shareButton.addTarget(self, action: "sharePressed", forControlEvents: ASControlNodeEvent.TouchUpInside)
/* snip */
// The implementation of ContentNavView#sharePressed()
func sharePressed() {
delegate.sharePressed()
}
所以,我在这里学到了一些东西:
objectWithID:
返回NSManagedObject
。就这样。无法保证您发送该消息的对象将返回与接收方相同类型的对象,因此测试返回的对象是处理此问题的最安全方法。因此,确定范围以减少或消除托管对象的线程问题是一个首要问题,它将彻底消除此问题NSThread#callStackSymbols
或其他一些API)获取崩溃报告时,总是会返回与我在这里显示的相同的垃圾。您所能做的最好的事情就是推断可能导致崩溃的词法范围,并梳理代码中可能出现的错误。我们不得不这样做,直到斯威夫特成熟你更新xcode了吗?尝试删除缓存文件实际上,在我看来,您非常了解如何在代码中查找问题。但是,您没有向我们显示任何代码,因此很难看到您的要求。除了“什么?”之外,似乎没有任何问题。@jycr753这篇撞车报告是用批判性语言来表示的。无论如何,我认为Xcode在这里帮不了什么忙。@matt问题是,是否有人能帮助揭开坠机报告的神秘面纱。我已经添加了回溯中提到的实现。但是你没有说它有什么神秘之处,所以什么是去神秘。看来你在ArticleImageProvider中崩溃了。但是你还没有展示出来……另一个解决方案——我不情愿地决定采用的解决方案——是在Swift成熟之前,主要使用目标C进行编码。
// Where I attach the action to my button in ContentNavView
shareButton.addTarget(self, action: "sharePressed", forControlEvents: ASControlNodeEvent.TouchUpInside)
/* snip */
// The implementation of ContentNavView#sharePressed()
func sharePressed() {
delegate.sharePressed()
}
// The implementation of DetailsViewController#sharePressed()
func sharePressed() {
if let cell = currentCell {
let activityViewController = BasicArticleSharingController.shareArticleActivityViewController(cell.article)
self.view.window?.rootViewController?.presentViewController(activityViewController, animated: true, completion: nil)
}
}
// The implementation of BasicArticleSharingController#shareArticleActivityViewController(::) up to the initializer
class func shareArticleActivityViewController(article: Article, track: Bool = true) -> UIActivityViewController {
var article = CoreDataManager.sharedManager.managedObjectContextForCurrentThread().objectWithID(article.objectID) as! Article
let activities = [
ArticleImageProvider(article: article), // Crash when calling this init?
ArticleLinkProvider(article: article)
]
/* snip */
}
// Implementation of the init that's crashing. Apparently Swift only reports the class that crashes, not the line that crashes, so here's the implementation that I thought wasn't relevant.
final public class ArticleImageProvider: UIActivityItemProvider {
let articleObjectID: NSManagedObjectID
init(article: Article) {
self.articleObjectID = article.objectID
let article: Article = CoreDataManager.sharedManager.managedObjectContextForCurrentThread().objectWithID(article.objectID) as! Article
let thumbnailCut = article.headlineImage?.cutWithShape(.Landscape)
if let path = thumbnailCut?.localURL?.path {
if let image = UIImage(contentsOfFile: path) {
super.init(placeholderItem: image)
}
else {
super.init(placeholderItem: UIImage())
}
} else {
super.init(placeholderItem: UIImage())
}
}
/* snip */
}