Swift:CoreData库中的断点

 不能深加工 发布于 2023-01-02 10:13

使用Swift的XCode 6 Beta 3.

在我的应用程序中,我使用CoreData.当我在模拟器中运行我的应用程序时,XCode会弹出调试器,并在CoreData库中的某处设置断点(参见屏幕截图).这在多个CoreData函数上发生,例如在插入新记录或从实体获取记录时.断点位置始终相同.

在此输入图像描述

这非常烦人.当我的应用程序从实体中获取10条记录时,我必须按下继续程序执行按钮10次.

由于此断点设置在机器代码的某处,因此断点检查器不会显示任何断点,因此我无法删除它.

有谁知道怎么摆脱它?

非常感谢.


编辑: backtrace-output:

(LLDB)BT*线#1:TID = 0x1d68b0,0x000000010a2f7fcd libswift_stdlib_core.dylib swift_dynamicCastClassUnconditional + 77, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) * frame #0: 0x000000010a2f7fcd libswift_stdlib_core.dylibswift_dynamicCastClassUnconditional + 77帧#1:0x000000010a0fbb85 GPS轨道GPS_Track.TrackListTableViewController.tableView (tableView=)(Swift.ImplicitlyUnwrappedOptional, cellForRowAtIndexPath : Swift.ImplicitlyUnwrappedOptional) -> Swift.Optional + 1125 at TrackListTableViewController.swift:53 frame #2: 0x000000010a0fc937 GPS Track@objc GPS_Track.TrackListTableViewController.tableView(GPS_Track.TrackListTableViewController)(Swift.ImplicitlyUnwrappedOptional,的cellForRowAtIndexPath:Swift.ImplicitlyUnwrappedOptional) - > Swift.Optional + 87在TrackListTableViewController.swift:0帧#3:0x000000010bc2f218 UIKit -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508 frame #4: 0x000000010bc0f340 UIKit- [UITableView _updateVisibleCellsNow:isRecursive:] + 2845帧#5:0x000000010bc24fea UIKit -[UITableView layoutSubviews] + 213 frame #6: 0x000000010bbb1ebd UIKit- [UIView(CALayerDelegate)layoutSublayersOfLayer:] + 519帧#7: 0x000000010b9c9598 QuartzCore -[CALayer layoutSublayers] + 150 frame #8: 0x000000010b9be1be QuartzCoreCA ::层:: layout_if_needed(CA ::交易*)+ 380帧#9:0x000000010b9be02e QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24 frame #10: 0x000000010b92cf16 QuartzCoreCA ::上下文:: commit_transaction(CA ::交易*)+ 242帧#11:0x000000010b92e022 QuartzCore CA::Transaction::commit() + 390 frame #12: 0x000000010b92e68d QuartzCoreCA ::交易:: observer_callback(__ CFRunLoopObserver*,无符号长,无效*)+ 89帧#13:0x000000010ab52927的CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 frame #14: 0x000000010ab52880 CoreFoundation__CFRunLoopDoObservers + 368帧#15:0x000000010ab480d3 CoreFoundation __CFRunLoopRun + 1123 frame #16: 0x000000010ab47a06 CoreFoundationCFRunLoopRunSpecific + 470帧#17:0x000000010e9e9abf GraphicsServices GSEventRunModal + 161 frame #18: 0x000000010bb39cf8 UIKitUIApplicationMain + 1282帧#19:0x000000010a0e6a5d GPS跟踪top_level_code + 77 at AppDelegate.swift:36 frame #20: 0x000000010a0e6a9a GPS Track主要+ 42在AppDelegate.swift:0帧#21:0x000000010d2e7145 libdyld.dylib`start + 1(lldb)

zisoft.. 8

我进一步跟踪它:只有在为实体使用自定义对象类时才会出现问题.例:

// User class, defined in User.swift
class User: NSManagedObject {
    @NSManaged var name: String
    @NSManaged var firstname: String
}


// --------------
// code somewhere else
let users = moc.executeFetchRequest(fetchRequest, error: &error)

for object in users {
    let user = object as User   // <-- breakpoint fired here
        println(user.name)
    }
}

解:

需要使用@objc指令使Objective C对自定义对象类可见:

// User class, defined in User.swift
@objc(User)    // <-- required!
class User: NSManagedObject {
    @NSManaged var name: String
    @NSManaged var firstname: String
}

感谢大家的帮助!

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有