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 libr
Do you have an All Exception breakpoint set?
Contrary to Apple's best practices CoreData uses exceptions in the normal flow of control.
If you add exception breakpoints you may break in CoreData. The solution is to remove or disable the exception breakpoint.
While the above answers all are technically correct
@zisoft is right, however if you're using custom NSManagedObject classes then you should always use @objc(User), not just because of this break point.
@Zaph may work also, as you're essentially not listening and if indeed it's a bug it should stop it from appearing
However you may still hit this kind of break point if you're not type checking. I suspect it's a breakpoint in the beta 4 but will become a crash in the next beta.
I solved the issue in my code as I was hitting on returning the managed object received from insertNewObjectForEntityForName as AnyObject and later saying as myclass when I used it. Fine as I knew it was my class. but actualy should have done something like this
func createMyEntity() -> MyClass{
if let entity : MyClass = NSEntityDescription.insertNewObjectForEntityForName("MyClass", inManagedObjectContext: self.managedObjectContext) as? MyClass
{
return entity;
}
return nil;
}
Obviously that's just one example, but if you're the hitting the break point in other places then hopefully this a good reference.
Not withstanding this still may just be a bug in beta 4 of xcode, but this is safer anyway.
Update -- It also checking that your data model class name matches as it later through a warning here an this may also be why the breakpoint was hit.
I fixed my version of this problem based on info in https://devforums.apple.com/message/1016337#1016337
NSManagedObject
-derived class and its relevant properties public
import MyApp
in MyClassTests.swift
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!
For anyone using Xcode 6.2
@objc
changes to your class i.e @objc(className)
*.xcdatamodeld
-> Configurations
(Default if nothing specified) -> add class against entity Thanks the last helped!!!