Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
884 views
in Technique[技术] by (71.8m points)

xcode - Swift: Breakpoint in CoreData library

XCode 6 Beta 3 using Swift.

In my App I use CoreData. When I run my App in simulator, XCode pops up the debugger with a breakpoint set somewhere in the CoreData library (see screenshot). This happens on several CoreData functions, for example when inserting new records or fetching records from an entity. The breakpoint position is always the same.

enter image description here

This is extremely annoying. When my App fetches 10 records from an entity I have to push the continue program execution button 10 times.

Because this breakpoint is set somewhere in machine code, the breakpoint inspector does not show any breakpoints so I cannot delete it.

Does anyone know how to get rid of it?

Many thanks.


Edit: backtrace-output:

(lldb) bt * thread #1: tid = 0x1d68b0, 0x000000010a2f7fcd libswift_stdlib_core.dylibswift_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 frame #1: 0x000000010a0fbb85 GPS TrackGPS_Track.TrackListTableViewController.tableView (tableView=<unavailable>)(Swift.ImplicitlyUnwrappedOptional<ObjectiveC.UITableView>, cellForRowAtIndexPath : Swift.ImplicitlyUnwrappedOptional<ObjectiveC.NSIndexPath>) -> Swift.Optional<ObjectiveC.UITableViewCell> + 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 at TrackListTableViewController.swift:0 frame #3: 0x000000010bc2f218 UIKit-[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508 frame #4: 0x000000010bc0f340 UIKit-[UITableView _updateVisibleCellsNow:isRecursive:] + 2845 frame #5: 0x000000010bc24fea UIKit-[UITableView layoutSubviews] + 213 frame #6: 0x000000010bbb1ebd UIKit-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 519 frame #7: 0x000000010b9c9598 QuartzCore-[CALayer layoutSublayers] + 150 frame #8: 0x000000010b9be1be QuartzCoreCA::Layer::layout_if_needed(CA::Transaction*) + 380 frame #9: 0x000000010b9be02e QuartzCoreCA::Layer::layout_and_display_if_needed(CA::Transaction*) + 24 frame #10: 0x000000010b92cf16 QuartzCoreCA::Context::commit_transaction(CA::Transaction*) + 242 frame #11: 0x000000010b92e022 QuartzCoreCA::Transaction::commit() + 390 frame #12: 0x000000010b92e68d QuartzCoreCA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 89 frame #13: 0x000000010ab52927 CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 frame #14: 0x000000010ab52880 CoreFoundation__CFRunLoopDoObservers + 368 frame #15: 0x000000010ab480d3 CoreFoundation__CFRunLoopRun + 1123 frame #16: 0x000000010ab47a06 CoreFoundationCFRunLoopRunSpecific + 470 frame #17: 0x000000010e9e9abf GraphicsServicesGSEventRunModal + 161 frame #18: 0x000000010bb39cf8 UIKitUIApplicationMain + 1282 frame #19: 0x000000010a0e6a5d GPS Tracktop_level_code + 77 at AppDelegate.swift:36 frame #20: 0x000000010a0e6a9a GPS Trackmain + 42 at AppDelegate.swift:0 frame #21: 0x000000010d2e7145 libdyld.dylib`start + 1 (lldb)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I tracked it down further: The problem only occurs when using custom object classes for the entities. Example:

// 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)
    }
}

SOLUTION:

One need to make the custom object class visible to Objective C using the @objc directive:

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

Thanks to all for your help!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...