在 Swift 中调试对象时重复引用 CoreData 实体
Repeating reference to CoreData Entity when debugging object in Swift
我可能只是错误地理解了这一点,但是当我创建一个 Exercise
实体并在调试器中查看它的内容时,我得到了对实体类型的重复引用。
Exercise+CoreDataProperties文件是标准的:
import Foundation
import CoreData
extension Exercise {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Exercise> {
return NSFetchRequest<Exercise>(entityName: "Exercise")
}
@NSManaged public var exerciseDuration: Int16
@NSManaged public var repeatNo: Int16
@NSManaged public var restDuration: Int16
@NSManaged public var exerciseName: String
@NSManaged public var id: UUID
@NSManaged public var associatedWorkout: NSSet?
}
// MARK: Generated accessors for associatedWorkout
extension Exercise {
@objc(addAssociatedWorkoutObject:)
@NSManaged public func addToAssociatedWorkout(_ value: WorkoutSet)
@objc(removeAssociatedWorkoutObject:)
@NSManaged public func removeFromAssociatedWorkout(_ value: WorkoutSet)
@objc(addAssociatedWorkout:)
@NSManaged public func addToAssociatedWorkout(_ values: NSSet)
@objc(removeAssociatedWorkout:)
@NSManaged public func removeFromAssociatedWorkout(_ values: NSSet)
}
extension Exercise : Identifiable {
}
这是 xcdatamodeld 配置:
知道为什么我在创建对象后无法在调试模式下查看对象的值吗?我是否在我的代码中做了什么导致这种重复?
您使用的变量视图无法查看托管对象(或大多数对象)的属性值。如果要检查 属性 值,请使用调试控制台。当您停在屏幕截图中的行时,您应该能够使用 po newExercise
查看 newExercise
的属性,或者您可以使用 po newExercise.exerciseName
等命令查看单个 [=15] =] 值。
我可能只是错误地理解了这一点,但是当我创建一个 Exercise
实体并在调试器中查看它的内容时,我得到了对实体类型的重复引用。
Exercise+CoreDataProperties文件是标准的:
import Foundation
import CoreData
extension Exercise {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Exercise> {
return NSFetchRequest<Exercise>(entityName: "Exercise")
}
@NSManaged public var exerciseDuration: Int16
@NSManaged public var repeatNo: Int16
@NSManaged public var restDuration: Int16
@NSManaged public var exerciseName: String
@NSManaged public var id: UUID
@NSManaged public var associatedWorkout: NSSet?
}
// MARK: Generated accessors for associatedWorkout
extension Exercise {
@objc(addAssociatedWorkoutObject:)
@NSManaged public func addToAssociatedWorkout(_ value: WorkoutSet)
@objc(removeAssociatedWorkoutObject:)
@NSManaged public func removeFromAssociatedWorkout(_ value: WorkoutSet)
@objc(addAssociatedWorkout:)
@NSManaged public func addToAssociatedWorkout(_ values: NSSet)
@objc(removeAssociatedWorkout:)
@NSManaged public func removeFromAssociatedWorkout(_ values: NSSet)
}
extension Exercise : Identifiable {
}
这是 xcdatamodeld 配置:
知道为什么我在创建对象后无法在调试模式下查看对象的值吗?我是否在我的代码中做了什么导致这种重复?
您使用的变量视图无法查看托管对象(或大多数对象)的属性值。如果要检查 属性 值,请使用调试控制台。当您停在屏幕截图中的行时,您应该能够使用 po newExercise
查看 newExercise
的属性,或者您可以使用 po newExercise.exerciseName
等命令查看单个 [=15] =] 值。